Question

In: Computer Science

Implement Java source code for a class called Temperature that does the following: a. Prompts the...

Implement Java source code for a class called Temperature that does the following:

a. Prompts the user to input a temperature
b. Prints “Too Hot!” when the input temperature is above 75
c. Prints “Too Cold!” when the input temperature is below 40
d. Prints “Just Right!” when the input temperature is 40 to 75
e. Be precise, include comments, prologue, etc. if needed.

Solutions

Expert Solution

Hello, I am putting java code as your requirement with comments. please go through it and if you have any problem, comment here. also If you are fine with the answer, give me a like.

import java.util.Scanner;

public class Temperature
{
   public static void main(String[] args) {
   // For Taking input from user
       Scanner scn = new Scanner(System.in);
  
       System.out.println("Enter Temperature:");
      
       // Temperature as integer input
       int temp = scn.nextInt();
       // If Temperature is too high means >75
   if(temp > 75){
   System.out.println("Too Hot!");
   }
   // If Temperature is too cool means <40
   else if(temp < 40){
   System.out.println("Too Cold!");
   }
   // otherwise this will execute which means Temperature between 40 and 75
   else{
   System.out.println("Just Right!");
   }
   }
}

Thank you.


Related Solutions

Java programming language should be used Implement a class called Voter. This class includes the following:...
Java programming language should be used Implement a class called Voter. This class includes the following: a name field, of type String. An id field, of type integer. A method String setName(String) that stores its input into the name attribute, and returns the name that was just assigned. A method int setID(int) that stores its input into the id attribute, and returns the id number that was just assigned. A method String getName() that return the name attribute. A method...
Write a Java class called GuessMyNumber that prompts the user for an integer n, tells the...
Write a Java class called GuessMyNumber that prompts the user for an integer n, tells the user to think of a number between 0 and n−1, then makes guesses as to what the number is. After each guess, the program must ask the user if the number is lower, higher, or correct. You must implement the divide-and-conquer algorithm from class. In particular, you should round up when the middle of your range is in between two integers. (For example, if...
JAVA Specify, design, and implement a class called PayCalculator. The class should have at least the...
JAVA Specify, design, and implement a class called PayCalculator. The class should have at least the following instance variables: employee’s name reportID: this should be unique. The first reportID must have a value of 1000 and for each new reportID you should increment by 10. hourly wage Include a suitable collection of constructors, mutator methods, accessor methods, and toString method. Also, add methods to perform the following tasks: Compute yearly salary - both the gross pay and net pay Increase...
I am to complete the following for Java but getting compiler errors...Implement a base class called...
I am to complete the following for Java but getting compiler errors...Implement a base class called Student that contains a name and major. Implement the subclass GraduateStudent, which adds a property called stipend. Here is what I have for code with the compiler error following. public class GraduateStudent extends Student {       private double stipend;       public GraduateStudent(String name, String major, double stipend) {               super(name);        super(major);           this.stipend = stipend;...
Code in Java Create a stack class to store integers and implement following methods: 1) void...
Code in Java Create a stack class to store integers and implement following methods: 1) void push(int num): This method will push an integer to the top of the stack. 2) int pop(): This method will return the value stored in the top of the stack. If the stack is empty this method will return -1. 3) void display(): This method will display all numbers in the stack from top to bottom (First item displayed will be the top value)....
In Java, design and implement a class called Cat. Each Cat class will contain three private...
In Java, design and implement a class called Cat. Each Cat class will contain three private variables - an integer representing its speed, a double representing its meowing loudness, and a String representing its name. Using the Random class, the constructor should set the speed to a random integer from 0 to 9, the meowing loudness to a random double, and the name to anything you want; the constructor should take no parameters. Write “get” and “set” methods for each...
write a java code to implement a linked list, called CupList, to hold a list of...
write a java code to implement a linked list, called CupList, to hold a list of Cups. 1.Define and write a Cup node class, called CupNode, to hold the following information about a cup: •number (cup number) •capacity (cup capacity in ml) •Write a method size() that returns the number of elements in the linkedlist CupList. •Write a method getNodeAt() that returns the reference to cup node object at a specific position given as a parameter of the method. •Write...
JAVA - Design and implement a class called Flight that represents an airline flight. It should...
JAVA - Design and implement a class called Flight that represents an airline flight. It should contain instance data that represent the airline name, the flight number, and the flight’s origin and destination cities. Define the Flight constructor to accept and initialize all instance data. Include getter and setter methods for all instance data. Include a toString method that returns a one-line description of the flight. Create a driver class called FlightTest, whose main method instantiates and updates several Flight...
in java Design and implement a class called Dog that contains instance data that represents the...
in java Design and implement a class called Dog that contains instance data that represents the dog’s name and age. Define the Dog constructor to accept and initialize instance data. Include getter and setter methods for the name and age. Include a method to compute and return the age of the dog in “person years” (seven times the dog’s age). Include a toString method that returns a one-line description of the dog. Create a Tester class called Kennel, whose main...
Use Java programming to implement the following: Implement the following methods in the UnorderedList class for...
Use Java programming to implement the following: Implement the following methods in the UnorderedList class for managing a singly linked list that cannot contain duplicates. Default constructor Create an empty list i.e., head is null. boolean insert(int data) Insert the given data into the end of the list. If the insertion is successful, the function returns true; otherwise, returns false. boolean delete(int data) Delete the node that contains the given data from the list. If the deletion is successful, the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT