Create a temperature demo program

Assignment Help Computer Engineering
Reference no: EM13323278

Create a Temperature class:
-Create methods to convert centigrade to fahrenheit and fahrenheit to centigrade.
-Make sure you take no input in this class and that it does not contain a main method.

Create a Temperature Demo program:
-Use your temperature class to create a temperature object.
-Ask the user for a value.
-Ask the user if the value is C or F.
-Display the user input and the result of the chosen operation to the screen.
-Repeat the program until the user chooses to quit.

My code below compiles correctly and meets all the requirements, but my methods need to be in a temperature class, not in the TemperatureDemo... Please help

my original code:

import java.util.Scanner;

public class TemperatureDemo {

public static void main(String[] args) {

char entry = 'e';

do {

Scanner in = new Scanner(System.in);

System.out.print("Enter a temperature: ");

double temp = in.nextDouble();

System.out.print("Centigrade or Fahrenheit? Enter c/f: ");

char unit = in.next().toLowerCase().charAt(0);

//methods

if(unit == 'f') {

System.out.println(temp + " Fahrenheit = " + (5 * (temp-32)/9) + " Centigrade");

}

else if(unit == 'c') {

System.out.println(temp + " Centigrade = " + (9 * (temp/5)+32) + " Fahrenheit");

}

else {

System.out.println("Invalid entry");

}

System.out.print("Enter q to quit or anything else to continue: ");

entry = in.next().toLowerCase().charAt(0);

} while(entry != 'q');

}

}

 

Reference no: EM13323278

Questions Cloud

Determine the initial acceleration of the metal cylinder : A 0.527 kg metal cylinder is placed inside the top of a plastic tube, the lower end of which is sealed off by an adjustable plunger, what is the initial acceleration of the metal cylinder
Show the parse tree for the expression 110 : The second grammar is unambiguous. This means that every expression in the language has exacty on parse tree. Show the parse tree for the expression 110.
Find its angular separation between central maxima : If wavelength is 5890 , and slits width is 0.25 mm, find its angular separation between central maxima
Determine total time for the compression wave to travel down : You are to perform a dynamic pile load test on a24-inch OD open ended homogeneous pipe pile. The pile has a shellthickness of 0.5 inch and is 80 feet long. Calculate: Compression wave velocity(hint: E=29x106 psi, g=490 pcf)
Create a temperature demo program : Make sure you take no input in this class and that it does not contain a main method.
Determine the pressure at the bottom of the tank : A large tank of water is full and has a depth of 10.0 m. What is the pressure at the bottom of the tank
Determine the pressure exerted on the floor by each leg : A 4.5-kg, three legged stool supports a 68-kg person. If each leg of the stool has a cross-sectional diameter of 3.0 cm, determine the pressure exerted on the floor by each leg
Determine the power required to run the compressor : Helium (Hrom an intie) at a rate of 1.5 lbm/s is compressed inan adibatic compressor from an intial condition of 70 F, 14.7 Psiato final condtion of 1070 F, 147 Psia. Determine The power required to run his compressor
Write a base class to hold basic computer information : Write a class that inherits the computer class for Windows computers.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Compute the dollar amount of money in a piggy bank

Write down a detailed set of instructions, in English, to calculate the dollar amount of money in a piggy bank that contains h half-dollars, q quarters, n nickels, d dimes and p pennies.

  Outline the importance of support systems and mechanisms

examine how creating Risk Management, Scope Change Control, and Communication Plan can help improve the management of any project.

  Make a use of microsoft project to create a project plan

make a Use of Microsoft Project to create a project plan

  A program that would calculate and print the parking charges

A parking garage charges a atleast fee of $2.00 to park for up to 3 hours. The garage charges an additional $0.50 per hour for each hour or part thereof in excess of 3 hours.

  Testing program using numbers of command line arguments

Test your program thoroughly utilizing different numbers of command line arguments.

  Define the process necessary to properly install

This solution gives students the resources and tips necessary to properly specify the process to replace a computer's power supply.

  When the user presses the start button

When the user presses the start button, a menu display of potential destinations is activated along with a message to user to choose a destination.

  Cpp file of the program

Student must submit each lab assignment along with two files: a working .cpp file of the program design and a screenshot of its program execution output in Word format.

  Show the accurate statement

Find out the error(s) in each of the following program segments. Show the corrected statement.

  Write down a c++ program that has a class called flight

Write down a C++ program that has a class called flight.

  What processes and properties would you include

Visual Basic.NET allows you to create your own classes. Provide an instance of a useful class you could create. What methods and properties would you include? Show an example of a method declaration for your class.

  Write down a program that includes a function picnic()

The passed floating-point number represents TOTAL amount of money to be spent on food. The function is to determine the quantity of HOTDOGS, HAMBURGERS,SALAD,PICKLES that can be purchaced, writing these values directly into the respective variable..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd