In this lab we create a temperature sensor simulator which will display a menu to the user asking them to choose what weather season simulation they want. Each season has a different value that we have to assign. Depending on what value the user inputs, there should be an output displaying the : First temperature generated, Last temperature generated, Lowest temperature generated, Highest temperature generated, Total sum of all temperatures generated, and Average for the season. In Lab 2 it;s basically an extension of lab 1 in which we create another class TemperatureSensorStats and with new methods in that class it would change how the temperature would be generated.


package lab2;

import java.util.Random;

public class TemperatureSensor1 
	//Random Method
	Random RanNum = new Random();

	//Getting Winter Temperature Class
	public int getWinterTemp()
		int WinterTemp=RanNum.nextInt(21)+20;
		return WinterTemp;

	//Getting Spring Temperature Class
	public int getSpringTemp()
		int SpringTemp=RanNum.nextInt(31)+40;
		return SpringTemp;

	//Getting Summer Temperature Class
	public int getSummerTemp()
		int SummerTemp=RanNum.nextInt(21)+70;
		return SummerTemp;

	//Getting Fall Temperature Class
	public int getFallTemp()
		int FallTemp=RanNum.nextInt(21)+40;
		return FallTemp;

	//Showing user the Output
	public void showOutput(double TotalTemp,double AveTemp, int FirstTemp,int LastTemp,int HighTemp, int LowTemp)
		System.out.println("Total Temperature of the season is: " + TotalTemp + " Degree");
		System.out.println("Average Temperature of the season is: " + AveTemp + " Degree");
		System.out.println("First Temperature of the season is: " + FirstTemp + " Degree");
		System.out.println("Last Temperature of the season is: " + LastTemp + " Degree");
		System.out.println("Highest Temperature of the season is: " + HighTemp + " Degree");
		System.out.println("Lowest Temperature of the season is: " + LowTemp + " Degree");




error message


Leave a Reply

Your email address will not be published. Required fields are marked *