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...
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)....
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...
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...
In java design and code a class named comparableTriangle that extends Triangle and implements Comparable. Implement...
In java design and code a class named comparableTriangle that extends Triangle and implements Comparable. Implement the compareTo method to compare the triangles on the basis of similarity. Draw the UML diagram for your classes. Write a Driver class (class which instantiates the comparableTriangle objects) to determine if two instances of ComparableTriangle objects are similar (sample output below). It should prompt the user to enter the 3 sides of each triangle and then display whether or not the are similar...
(JAVA) Implement a ‘runnable’ Class called “NumericAnalyzer”. Here’s the functional behavior that must be implemented. NumericAnalyzer...
(JAVA) Implement a ‘runnable’ Class called “NumericAnalyzer”. Here’s the functional behavior that must be implemented. NumericAnalyzer will accept a list of 1 or more numbers as command line arguments. These numeric values do not need to be ordered (although you’ll need to display these values sorted ascendingly). NOTE: Don’t prompt the user for input – this is an exercise passing values to your program via the command line! Error checking: if the user fails to pass in parameters, the program...
using Java Implement a class called Binomial_Coefficient o Your class has 2 int attributes, namely K...
using Java Implement a class called Binomial_Coefficient o Your class has 2 int attributes, namely K and n o Create an overloaded constructor to initialize the variables into any positive integers such that n > k > 0o Create a method that calculates the value of binomial coefficient, C(n,k) , using the following rule: ▪ For an array of size (n+1) X (k+1) ▪ Array [n][k] = Array[n-1][ k-1]+ Array[n-1] [k]▪ Array[n][0]= Array[n][n] = 1 ▪ Hence, C(n,k) = array...
language is java Use method overloading to code an operation class called CircularComputing in which there...
language is java Use method overloading to code an operation class called CircularComputing in which there are 3 overloaded methods as follows: computeObject(double radius)-compute area of a circle computeObject(double radius, double height)-compute area of a cylinder computeObject(double radiusOutside, double radiusInside, double height)-compute volume of a cylindrical object These overloaded methods must have a return of computing result in each Then override toString() method so it will return the object name, the field data, and computing result Code a driver class...
in JAVA: implement a class called tree (from scratch) please be simple so i can understand...
in JAVA: implement a class called tree (from scratch) please be simple so i can understand thanks! tree(root) node(value, leftchild,rightchild) method: insert(value)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT