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

Ok tell me First did u develoP th7s cofe if so HoW u are finding the *
Just want to know if Ur able to find the *

if you had checked the code, you'ld probably have seen that the chances of it compiling, let alone running, are pretty small.

for instance:

while(city != *)

with city being a String, should probably be

while ( !city.equals("*"))

also, the indentation isn't very clear. I can see where that loop ends, but is that truly the place the OP wants it to stop (for instance)

U can either use endsWith or gO for breaking string into char array depends on u as char array will require a loop to find d * wich can hit d Performance

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.