Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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');

}

}

 

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9902580

Have any Question?


Related Questions in Computer Engineering

Assignmentanalyze web programs in order to test debug and

Assignment Analyze web programs in order to test, debug, and improve them. Provide your own original example for each of the explanations you provide. Explain how geologation can determine your location. Discuss the accu ...

Question you have been asked to help promote a new bill in

Question: You have been asked to help promote a new bill in your state, to which there is much opposition to this bill. Discuss what distributive bargaining is. Discuss the pros and cons which might arise toward the pass ...

Every day your friend commutes to school on the subway at 9

Every day your friend commutes to school on the subway at 9 AM. If the subway is on time, she will stop for a $3 coffee on the way to class. If the subway is delayed she skips the coffee and goes straight to class. The p ...

Question introduction to management information systemsread

Question: Introduction to Management Information Systems Read at least three (3) academically reviewed articles on Management Information Systems and complete the following activities: (Wikipedia articles will not be acc ...

Refer to the reading e-business strategy how to benefit

Refer to the reading, "E-Business Strategy: How to Benefit From a Hype" and review its alignment between such models as SWOT and Five Forces and the e-business that it uses as a model. In your posting, address the follow ...

Systems analysis project personal trainer inc owns and

Systems Analysis project Personal Trainer, Inc. owns and operates fitness centers in a dozen Midwestern cities. The centers have done well, and the company is planning an international expansion by opening a new "superce ...

Sketch out a simple network management system for ndas what

Sketch out a simple network management system for NDAS. What software and hardware support would you recommend? Be sure you justify the information items collected and reported for this system, as well as your software a ...

Question suppose we are interested in studying a dna

Question : Suppose we are interested in studying a DNA sequence which consists of four bases: A, C, G, and T. Write a program that does the following: Create a random DNA string of length 50. Determine how many times A o ...

Define risk and explain why this concept is important to

Define risk and explain why this concept is important to small business managers.

Query to reterieve data from a customers table in mysql for

Query to reterieve data from a customers table in MySQL for instance who have not placed any orders yet, How to sort results by customers number,How to Modify the query to list customers who have placed fewer than five o ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As