Returning Arrays On Temperature Table?

Apr 19, 2014

I am having trouble returning the DAY and Month that the high and low temperatures occurred on (right now I am only returning the int value) I also need to show how many days were <33 degrees and >75 degrees. I have done a lot of trial and error and searching. I set the String arrays but am failing at tying them in and calling them with the high and low temps.

package nyctemp;
public class NYCtemp {
public static void main(String[] args) {
String[] days = {"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"};
String[] months = {"January", "February", "March", "April",

[code]....

View Replies


ADVERTISEMENT

Returning Values From Arrays

Nov 22, 2014

I have created a class and a matrix of doubles (or at least, I think I have, that's partly what I want to verify).I need to return the values of the array,Here is my class:

public class example{
double[][] Position=new double[2][11];
double calculate(){
for (int time=0;time<=10;time=time+1){
Position[1][time]=time;
Position[2][time]=time+1;
double A=Position[2][time];
return A;
}
}
}

I am getting the error: "This method must return a result of type double", though to me it looks like I am returning double (A).

View Replies View Related

Returning Values From Table?

Apr 6, 2015

This simple program should build a new table with random values and on the getValue method (perhaps called from othe TestClass) return back content of particular cell. why my getValue method doesn't work. Nay! It returns error while compilation.

import java.util.Random;
class TablicaIntowa{
public int getValue(int a){
return tabl[a];
} //getValue method end

[Code]....

View Replies View Related

GUI Temperature Converter

May 4, 2015

I am having calculation issues converting Fahrenheit to Celsius. The Celsius to Fahrenheit is working properly.

private void convertButtonActionPerformed(java.awt.event.ActionEvent evt) {
int tempFahr = (int)((Double.parseDouble(tempText.getText()))
* 1.8 + 32);// Calculate Fahrenheit to Celsuis:
fahrenheitLabel.setText(tempFahr + "Fehrenheit");
}

[code]...

View Replies View Related

What Is The Difference Between Regular Arrays And Multi Dimensional Arrays

Jun 28, 2014

I mainly would like to know is a int[4][4] or a int [4*4] is more efficient to use. Which takes more storage? Which requires more to process? that kind of stuff.

View Replies View Related

Program To Convert Temperature

Apr 24, 2014

Write a program that will provide temperature conversions between degrees Fahrenheit and degrees Celsius. Provide a method that will take an argument representing a temperature in Fahrenheit degrees and return the equivalent temperature in degrees Celsius. Also provide a method that will take an argument representing a temperature in degrees Celsius and return the equivalent temperature in degrees Fahrenheit. Conversion formulas are as follows: F = 9./5. * C + 32, C = 5./9. * ( F - 32 ), where F = Fahrenheit temperature and C = Celsius temperature. You must prompt for input using the Input class methods that are provided as a download for this unit.

I have two questions, 1st is why won't I get an output from my program when I run it? 2nd is how do I prompt for input using the Input class methods downloaded? The downloaded files are in .class form, and won't show any output when I run them.My code is:

import java.util.*;
public class temp
{
public static void main ( String [] args )
{
Scanner in = new Scanner(System.in);

[code]...

View Replies View Related

High / Low / Average Temperature

Nov 19, 2014

I am trying to write a code that asks the user to enter a temperature for each day of the week and then it prints out the high temperature, the low temperature, and the average temperature. This is the code I have so far:

import java.util.*;
import java.text.DecimalFormat;
public class Lab10 {
public static void main(String[] args) {
java.util.Scanner input = new java.util.Scanner(System.in);
int high, low, i, sum;
double avg;
[Code] ....

There are a few issues that I am having.

1. I can't for the life of me figure out how to make it print the low temperature
2. I had it running perfectly until I changed one thing and now I get a compile error saying that the last 5 statements are unreachable. (lines 32-37)

View Replies View Related

Temperature Conversion GUI Java

Apr 21, 2015

I'm having trouble getting the text entered in my JTextField to be converted to the conversion formula. The line I'm getting error in is:

String text = text.getText();

Also I created another JTextField in which I want the answer to be displayed in, but I'm not too sure how to go about that.
This is my attempt at it, but it doesn't work because it doesn't make sense;
result.setText1(Integer.toString(celsius));

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class TempConversion extends JFrame
{
private final JLabel ask;
private final JLabel result;
private final JTextField text;
private final JTextField text1;

[code]....

View Replies View Related

Will Not Average For High Temperature

Apr 21, 2014

This program will not give me the average high temperature for the week and I cannot figure out why! Every time it only spits out "0" whereas the average low temperature works great..

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Temps_Grid_Keenan extends JFrame
{
private static final long serialVersionUID = 1L;
private static final int WIDTH = 400;
private static final int HEIGHT = 500;
 
private JTextField high1Field, low1Field, high2Field, low2Field;
private JTextField high3Field, low3Field, high4Field, low4Field;
private JTextField high5Field, low5Field, high6Field, low6Field;
private JTextField high7Field, low7Field, ave_highField, ave_lowField;
 
[code]....

View Replies View Related

Temperature Conversion Celsius To Fahrenheit

Jun 16, 2014

I have followed the instructions carefully but the conversion values are not correct.

Write a program that displays a table of the Celsius temperatures 0 through 20 and their Fahrenheit equivalents. The formula for converting a temperature from Celsius to Fahrenheit is
F - | C + 32
where ¥ is the Fahrenheit temperature and C is the Celsius temperature. Your program must use a loop to display the table.

Code

public class TempConversion
{
public static void main(String[] args) {
for(double i = 0; i <= 20.0; i++) {

[Code] ....

View Replies View Related

Formatting Decimals (Two Temperature Values)

Jan 30, 2015

I'm trying to format two temperature values using String.format.

return String.format("% 5.1f", temperature) + 'u2109' + " / " + String.format("% 5.1f", temperature2) + 'u2109';

I need all of that to be combined into a single String.format and include the / and unicode symbols for degree fahrenheit. How String.format works so that I can figure out how to achieve that? I've tried a few websites but none of them explain it to the extent that I need to use it.

View Replies View Related

Printing Errors If F Or C Isn't Entered For Temperature Type

Nov 14, 2014

I am trying to get it to print out an error if F or C isn't entered for the temperature type, but the code I am taking from one of my other similar programs isn't working for some reason.

Also, when I type a string in the temperature I get an exception....I can do the same with that as I would the temp type? I think I may just be putting the code in the wrong spot and thats why it isn't working..

public static void main(String[] args)

Scanner input = new Scanner(System.in);
System.out.print("Please enter F for Fahrenheit or C for Celsius: ");
String fOrC = input.next();

[Code] ....

View Replies View Related

JavaFX 2.0 :: How To Define Cell In The Table By Table Event

Mar 23, 2015

How to define Cell in the table by table event?
 
I need to process one component drag to the table. I misunderstand, how I can see to which Cell fall the component. I tried to use Event and Mouse event handlers in my custom Cell, but they do not work. I can copy the drag event to the table and table handles it, but how to get needed Cell I cant understand.

View Replies View Related

Create A Java File That Will Print Out Temperature In Fahrenheit?

Jan 11, 2014

I am trying to create a java file that will print out the temperature in Fahrenheit. This is my code.

import java.util.Scanner;
 public class TemperatureConverter { 
public static void main(String[] args) {
 float temperature;
Scanner in= new Scanner(System.in);
 System.out.printf("Enter temperature in degrees Celsius: ");
temperature = in.nextInt();
//Getting a red X next to this line.
fahrenheit = temperature * 9/5 +32;
//Add this line
System.out.printf(+temperature + " degrees Celsius is " + fahrenheit + " degrees Fahrenheit.");
 //System.out.println(temp1 + " degrees celsius is " + fahrenheit + " degrees Fahrenheit.");

}

I need to know what I am doing wrong. Using Eclipse as my platform. I have entered comments where I am getting red X's.

The error I get when I run the program.

Exception in thread "main" java.lang.Error: Unresolved compilation problems:
fahrenheit cannot be resolved to a variable
fahrenheit cannot be resolved to a variable
at TemperatureConverter.main(TemperatureConverter.jav a:24)

View Replies View Related

Monthly Temperature Chart Of Two Places - Array / While Loops

May 29, 2014

I started taking a java programming class javascript eclipse The program says it wants a monthly temperature chart of two places..Declare an array of values for Blueville temperatures and another array for Orlando temperatures. Then, use what you have learned to produce a program to output the following table:

Blueville Monthly temperatures

jan feb mar apr may jun jul aug sep oct nov dec

3 3 5 10 16 20 24 23 16 10 5 3

Orlando Monthly Temperatures

jan feb mar apr may jun jul aug sep oct nov dec

14 16 12 23 24 25 27 30 25 22 17 15

The warmest month in Blueville is _______

The warmest month in Orlando is ________

The month with the greatest temperature spread is __________

View Replies View Related

Take Input Of Temperature In Fahrenheit And Convert It To Celsius And Kelvin

Oct 28, 2014

I’m trying to write a program in Java that will take the input of a temperature in Fahrenheit and convert it to Celsius and Kelvin. This is what I have so far but when I run the program on Eclipse it says the temp. in Celsius is infinity and the same for kelvin. Why is it not preforming the operation and spiting out the correct numbers?

import java.util.Scanner;
public class Temperature {
public static void main(String[] args) {
// This program converts temperatures from Fahrenheit to Celsius to Kelvin.
double temperature1;// operands
double temperature2;
double temperature3;

[Code] ....

View Replies View Related

ArrayIndexOutOfBoundsException In A Single Dimensional Array For Temperature Conversion

Aug 31, 2014

I have a simple code for temperature conversion using single dimensional array, but I am getting ArrayIndexOutOfBoundsException error.

import java.io.*;
class arraycelcius
{
public static void main()throws IOException
{
InputStreamReader read = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(read);

[code]...

View Replies View Related

Adding Data In Table But The Table Is In Another Frame

Mar 13, 2014

This is my codes in a button that if I click it . that information will send to Jtable but the problem is the jtable is in another frame so how can i connect this ?

DefaultTableModel model = (DefaultTableModel)
new admin().tableBagtags.getModel();
if (txtName.getText().equals("")) {
JOptionPane.showMessageDialog(null, "Please fill out all fields.", "Error!", JOptionPane.ERROR_MESSAGE);

[Code] .....

View Replies View Related

JSF :: Unable To Add Mysql Table Columns To Table

Apr 29, 2014

I'm trying to add some mysql table columns to JSF table. And I'm getting error:

/index.xhtml: The class 'logon.User' does not have the property 'description'.

User.java
package logon;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

[Code]...

View Replies View Related

Thermostat - Showcase Time Passing And Temperature Reaching Desired Setting

Feb 25, 2014

Here is the question:

-In your main, you should create a thermostat and thoroughly test it. Be sure to showcase time passing and the temperature reaching the desired setting. Also, showcase switching modes from heating to cooling.

My question is, once it reaches the desired temp, would the thermostat turn off, and then how do you show switching from heating and cooling.

This is what prints.

Thermostat is: true Thermostat is: false The desired temp: 70.0 The current temp: 69.0
Tue Feb 25 19:06:21 CST 2014
Tue Feb 25 20:06:21 CST 2014
Thermostat is: true Thermostat is: false The desired temp: 70.0 The current temp: 70.0

Here is my Class:

import java.util.Random;
import java.util.Date;
public class Thermostat {
private double currentTemp;
private double desiredTemp;
private double heatingThreshold;
private double coolingThreshold;

[Code] .....

View Replies View Related

Make A Program To Calculate Average Temperature And Annual Precipitation In Jacksonville

Oct 4, 2014

I wasn't supposed to use the % in front of f.I have to make a program to calculate the average temperature and annual precipitation in Jacksonville. I get this error on line 49:

java.util.IllegalFormatPrecisionException;
null (in java.util.Formatter$FormatSpecifier)

I don't get any errors during compilation.Here is my code (I'm not using the system selection yet):

import java.util.Scanner;
public class AnnualClimate1
{
public static void main(String[] args)
{
double[] temperaturesInJacksonville = {53.1, 55.8, 61.6, 66.6, 73.4, 79.1, 81.6, 80.8, 77.8, 69.4, 61.7, 55.0};

[code]....

View Replies View Related

Temperature Conversion Project - Send Input Value To Calculation Area And Get Value To Display In JLabel

Sep 30, 2014

The problem I'm trying to resolve now is getting my ActionEvent to send the value input in the JTextArea out to be calculated, then to display the result in my result JLabel.

Here is an image of the GUI :

The basic procedure the teacher is asking for is the user is supposed to enter a temperature in the input. The user then clicks the input scale, and then on the output scale selection the converted value is to be displayed in the output area.

As I mentioned my problem is in the sending of the input value to my calculation area, and getting the value to display in the JLabel.

How should I approach this solution? Do I need to have a listener after the JTextArea of the input box? Will that allow me to limit the input values to numbers only?

final JTextArea inputText = new JTextArea("" + (char)176,1,4);
//ReadConsole equivalent to specific input was a number?

Here is the section of code my ActionListener is:

//celOut represents the Celcius output scale JRadioButton.
celOut.addActionListener (new ActionListener () {

@Override
public void actionPerformed(ActionEvent e) {
//if the Celcius Input Scale is selected.
if(cel.isSelected())

[Code] ....

All the calculations are required to occur in a separate java file, which what I think is tripping me up. How do I send a value from the JTextArea into the Calc.celToFahr method?

//contents of my Calc.java calculation class.
public class Calc {
public static double celToFahr(double cel){
return cel * (9./5.) + 32.;
}
public static double fahrToCel(double fahr){
return (fahr - 32.)*(5./9.);
}
}

View Replies View Related

Why Method Is Not Returning A Value

Apr 29, 2014

I'm new to Java and I have a problem with a method, I can't see the code of the method, I just have a jar, but it should return a boolean, something like this:

boolean band = false;
band = TestClass.testMethod("blabla");
// band = false

The problem is that the method seems that is returning nothing (band remain false), and if I initialize band to true:

boolean band = false;
band = TestClass.testMethod("blabla");
// band = true

band remain true, in other words, the value of band is never modified, the question is, how is this possible? because it should return the same value on both calls, true or false, no matter the initial value of the variable that is receiving the returning value of the method.

View Replies View Related

Returning A Result And Then Using It In Main

Jan 4, 2015

I've made a class called Car with a method which will tell me a category for the engine size regarding the actual size (which I've included in the main just so I could see if it works) but everytime I test it I get an error.

public class Car {
public String b;
public String c;
public double es;
public double cs; 
public String getCategory() {
if (es < 1.3)

[Code] ....

Figured it out. Was missing parenthesis on audiCar.getCategory();

View Replies View Related

Why Terminal Not Returning Results To IDE

May 14, 2014

i am trying to run a command in terminal the code is below if i run the command in terminal it works fine however when i run it from netbeans with code below nothing gets printed. however if i run a different command such as (ip addr) it works fine?

public static void a() throws IOException{
ArrayList lister=new ArrayList();
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("ps -ef | grep firefox");// the command i am trying to run to get pid of application
InputStream stderr = proc.getInputStream();

[Code] ....

View Replies View Related

Returning A String To The Main?

Oct 12, 2014

I am writing a code where in the first method the question will ask whats your favorite website. for example www.javaprogrammingforums.com...when it outputs it will read just "javaprogrammingforums" without the www. and the .com.

Because the program will ask a series of questions in the main, I would like website question to be returned to the main. Here is my code, and what can I do?

import java.util.Scanner;
public class chapter3 {
public static String website(Scanner kb) {
String website;
System.out.println("What is your favorite website?");
website = kb.next();

[Code] ......

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved