Lab 1

Objective: The objective of this lab experiment was to create a temperature sensor simulator that produces random values depending which season the user selects.

LAB1

import java.util.Scanner;
public class Temperature {

	public static void main(String[] args) {
		
		int option;
		int value;
		int simulations;
		
		Scanner input = new Scanner( System.in );
				
		System.out.println("Choose What Season to Simulate:");
		System.out.println();
		System.out.println("1 = Winter");
		System.out.println("2 = Spring");
		System.out.println("3 = Summer");
		System.out.println("4 = Fall");
		System.out.println("5 = Exit");
		System.out.println();
		System.out.print("Option: ");
		
		option = input.nextInt();
		
		System.out.println("How many simulations do you want to do?");
		
		simulations = input.nextInt();
		
		// TODO Auto-generated method stub

		
		if (option == 1){
			System.out.println("          Winter:");
			value = 20 + (int)(Math.random() * ((40 - 20) + 1));
			// standard: value = Min + (int)(Math.random() * ((Max - Min) + 1));
			System.out.println(value);
		}
		
		else if (option == 2){
			System.out.println("          Spring:");
			value = 40 + (int)(Math.random() * ((70 - 40) + 1));
			// standard: value = Min + (int)(Math.random() * ((Max - Min) + 1));
			System.out.println(value);
		}		
		
		else if (option == 3){
			System.out.println("          Summer:");
			value = 70 + (int)(Math.random() * ((90 - 70) + 1));
			// standard: value = Min + (int)(Math.random() * ((Max - Min) + 1));
			System.out.println(value);
		}		
		else if (option == 4){
			System.out.println("          Fall:");
			value = 40 + (int)(Math.random() * ((60 - 40) + 1));
			// standard: value = Min + (int)(Math.random() * ((Max - Min) + 1));
			System.out.println(value);
		}		
		
		else {
			System.out.println("          Program will now end....");
			System.exit(0);
		}		
		
}
}

Leave a Reply

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