Hi Everyone, I've been working on creating this code for a project I've been working on but I can't seem to get it to work. I'm creating a service class that I can then pass to a client class that will read a list of cities that ends in a "*" and then for each city read a list of tempratures that ends with a "0". It then has to calculate the average temprature, highest and lowest, and then output them along with any tempratures over 100. I've talked to my professor and she told me that the solution is a nested while loop, and that the prompts for the final program should be in a seprate client class. I also need to output the totals for each catagory. The thing is, I'm having a lot of trouble trying to figure out how to use this service class I've created in the client to get the data I need. My professor can't seem to explain it in a way I can understand, so I'm hoping for some help.
Heres my Service Class
public class WeatherInput
{
private static double tempAverage = 0;
private static double tempHigh = 0;
private static double tempLow = 0;
private static double tempHundred = 0;
public static String newCity = new String();
public static String city = new String();
public static void tempCalc(double temp)
{
while(city != *)
{
city = newCity;
}
while(temp != 0)
{
tempAverage = (temp + temp)/2;
if(tempHigh > temp)
tempHigh = temp;
if(tempLow < temp)
tempLow = temp;
if(temp > 100)
tempHundred = temp;
temp++;
}
System.out.print(tempAverage);
}
}
And here's what I have for a Client Class
//----------------------Import Statments--------------------------------------------
import java.util.*; //For Scanner and class
//----------------------------------------------------------------------------------
//Class Name: Prog2
//Description: This class has one method, the main method
//----------------------------------------------------------------------------------
public class Prog2
{
//-------------------------------------------------------------------------------
//Method Name: main
//Description:This prompts the user for information on carpets, and returns cost
// and amount of yards needed
//-------------------------------------------------------------------------------
public static void main(String[] args)
{
//-----------------------Local Constants--------------------------------------
//-----------------------Local Variables--------------------------------------
double temp;
//-----------------------Objects----------------------------------------------
Scanner scanner = new Scanner(System.in);
String city = new String();
Weatherinput input = new Weatherinput();
Weatherinput input2 = new Weatherinput();
input.tempCalc
//---------------------Method Body--------------------------------------------
System.out.print("Please enter the names of the cities, ending in a *");
city = scanner.next();
System.out.print("Please enter the tempratures, ending in a 0");
temp = scanner.nextDouble();
}//End main method
}//End class Prog2