Note that there are some explanatory texts on larger screens.

plurals
  1. POProject on Imputing Weather Data
    primarykey
    data
    text
    <p>I keep getting the message</p> <blockquote> <p>Exception in thread "main" java.lang.NoSuchMethodError: WeatherInput: method ()V not found</p> </blockquote> <p>in my client class for this project I'm working on and I'm not sure why, I was wondering if anyone here could see what I'm missing?</p> <p>Here's my service class:</p> <pre><code>class WeatherInput { private static final String NEWLINE = "\n"; private double temp; private double tempAverage; private double tempHigh; private double tempLow; private double tempHundred; public String newCity = new String(); public String city = new String(); public WeatherInput( String city) { temp = 0; tempAverage = 0; tempHigh = 0; tempLow = 0; tempHundred = 0; newCity = city; } public void setTemp( double temprature) { temp = temp; } public void tempCalc(String city) { while(!city.equals("*")) { city = newCity; } while(temp != 0) { tempAverage = (temp + temp)/2; if(tempHigh &gt; temp) tempHigh = temp; if(tempLow &lt; temp) tempLow = temp; if(temp &gt; 100) tempHundred = temp; temp++; } System.out.print(tempAverage); } public String printString(){ return NEWLINE + "Statistics for: " + newCity + "Average: " + tempAverage + "High: " + tempHigh + "Low: " + "Over 100: " + tempHundred + NEWLINE; } } </code></pre> <p>And this is my client:</p> <pre><code>import java.util.*; //For Scanner and class //---------------------------------------------------------------------------------- //Class Name: KosmowsiProg2 //Description: This class has one method, the main method //---------------------------------------------------------------------------------- public class KosmowskiProg2 { //------------------------------------------------------------------------------- //Method Name: main //------------------------------------------------------------------------------- public static void main(String[] args) { //-----------------------Local Constants-------------------------------------- //-----------------------Local Variables-------------------------------------- double newTemp; //-----------------------Objects---------------------------------------------- Scanner scanner = new Scanner(System.in); String city = new String(); String inputCity = new String(); WeatherInput input = new WeatherInput(); WeatherInput input2 = new WeatherInput(); //---------------------Method Body-------------------------------------------- System.out.print("Please enter the names of the cities, ending in a *"); inputCity = scanner.next(); System.out.print("Please enter the tempratures, ending in a 0"); newTemp = scanner.nextDouble(); input.setTemp(newTemp); input.tempCalc(inputCity); }//End main method private static void printResults(WeatherInput in){ System.out.print(in.printString()); } }//End class KosmowskiProg2 </code></pre> <p>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 temperature, highest and lowest, and then output them along with any temperatures 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 separate client class. I also need to output the totals for each category. 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.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload