Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 2, Problem 2.1PE

(Convert Celsius to Fahrenheit) Write a program that reads a Celsius degree in a double value from the console, then converts it to Fahrenheit, and displays the result. The formula for the conversion is as follows:

fahrenheit = (9 / 5) * celsius + 32

Hint: In Java, 9 / 5 is 1, but 9.0 / 5 is 1.8.

Here is a sample run:

Chapter 2, Problem 2.1PE, (Convert Celsius to Fahrenheit) Write a program that reads a Celsius degree in a double value from

Expert Solution & Answer
Check Mark
Program Plan Intro

Convert Celsius to Fahrenheit

Program Plan:

  • Define the class
    • Define the main method using public static main.
      • Declare the required variables.
      • Prompt the user to enter Celsius value.
      • Read the input
      • Convert it into Fahrenheit value.
      • Display the result on the screen.
Program Description Answer

The below program is used to convert Celsius to Fahrenheit.

Explanation of Solution

Program:

//class definition

public class Cel_Far

{

//Main method

public static void main(String[] args)

{

//declare scanner variable

Scanner in = new Scanner(System.in);

// Prompt the user to enter Celsius

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

//read the input

double celsius = in.nextDouble();

// Convert Celsius to Fahrenheit

double fh = (9.0 / 5) * celsius + 32;

// Display the result on the screen

System.out.println(celsius + " Celsius is " +

fh + " Fahrenheit");

}

}

Sample Output

Enter a temperature in Celsius: 43.5

43.5 Celsius is 110.3 Fahrenheit

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
03:32
Students have asked these similar questions
(Display Magic Numbers) Display the first N magic numbers, where N is a positive number that the user provides as input. Here, a magic number is a number whose sum of its digits eventually leads to 1. For example, 1234 is a magic number because 1+2+3+4 = 10 and 1 +0 = 1, while 1235 is not (1 +2+ 3 +5 = 11 and 1 +1 = 2). Write a program that prints out the first N magic numbers, seven on each line. Here is the sample output: Enter a positive integer number: 30 1 10 19 28 37 46 55 64 73 82 91 100 109 118 127 136 145 154 163 172 181 190 199 208 217 226 235 244 253 262 You are required to use the following function prototype: bool isMagic(int value); // Returns true if value is a magic number The outline of this function will be as follows: Step 1: Calculate the sum of digits of value Step 2: Repeat Step 1 until we get a single digit Step 3: If the resulting sum is equal to 1 then it is a magic number, otherwise not
(PLEASE USE BASIC  JAVA NOT COMPLEX I AM A BEGINNER THANKS) Canadian phone number has the following format: +1 (604) 295- 8959 Area Code= Three digits starting with 2-9Prefix= Three digits starting with 2-9Subscriber= Any four digits 0-9Write a java program, using loops, that asks the user to enter a phone number then if correct print theArea Code, Prefix, and Subscriber numbers. If not correct, print what is wrong. Sample run:Enter a number or -99 to quit: +1 (604) 277-9999The number is correct with area code: 604, prefix 277, and subscriber 9999Enter a number or -99 to quit: 1 (104) 277-0123Country code doesn’t start with + and area code doesn’t start with a 2-9 number.
Please Explain the Steps. (In Java Programming)   See expected output below.   Create a new Java application called "WeightedAvgDropSmallest" (without the quotation marks) according to the following guidelines.   The program prompts the user for five to ten numbers all on one line, separated by spaces, calculates the weighted average of all those numbers except the lowest n numbers, where n and the weight are also given by the user, and displays all the numbers, the weight, the number of lowest numbers dropped, and the calculated average to the user. The program uses methods to: Get the numbers used to calculate the average. Get the number of lowest numbers to drop before calculating the average. Get the weight, a double greater than 0 and less than or equal to 1. Calculate the weighted average of the numbers (except the lowest n numbers) entered by the user. Print the results. 1. The first method should take no arguments and return an array list of doubles. 2. The second method…

Chapter 2 Solutions

Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)

Ch. 2.9 - Prob. 2.9.2CPCh. 2.9 - Prob. 2.9.3CPCh. 2.9 - Prob. 2.9.4CPCh. 2.9 - Prob. 2.9.5CPCh. 2.9 - Prob. 2.9.6CPCh. 2.9 - Write a statement to display the result of 23.5.Ch. 2.9 - Suppose m and r are integers. Write a Java...Ch. 2.10 - How many accurate digits are stored in a f1oat or...Ch. 2.10 - Prob. 2.10.2CPCh. 2.10 - Prob. 2.10.3CPCh. 2.10 - Which of the following are correct literals?...Ch. 2.11 - How would you write the following arithmetic...Ch. 2.12 - Prob. 2.12.1CPCh. 2.13 - Prob. 2.13.1CPCh. 2.14 - Which of these statements are true? a. Any...Ch. 2.14 - Show the output of the following code: int a = 6;...Ch. 2.15 - Prob. 2.15.1CPCh. 2.15 - Prob. 2.15.2CPCh. 2.15 - Show the following output: float f =12.5F; int i =...Ch. 2.15 - If you change (int) (tax 100) / 100.0 to (int)...Ch. 2.15 - Prob. 2.15.5CPCh. 2.15 - Write an expression that rounds up a double value...Ch. 2.16 - How would you write the following arithmetic...Ch. 2.17 - Show the output of Listing 2.10 with the input...Ch. 2.18 - Can you declare a variable as int and later...Ch. 2.18 - Prob. 2.18.2CPCh. 2.18 - Will overflow cause a runtime error?Ch. 2.18 - Prob. 2.18.4CPCh. 2 - (Convert Celsius to Fahrenheit) Write a program...Ch. 2 - (Compute the volume of a cylinder) Write a program...Ch. 2 - (Convert feet into meters) Write a program that...Ch. 2 - (Convert pounds into kilograms) Write a program...Ch. 2 - (Financial application: calculate tips) Write a...Ch. 2 - (Sum the digits in an integer) Write a program...Ch. 2 - (Find the number of years) Write a program that...Ch. 2 - (Current time) Listing 2.7. ShowCurrentTime.java,...Ch. 2 - (Physics: acceleration) Average acceleration is...Ch. 2 - (Science: calculating energy) Write a program that...Ch. 2 - (Population projection) Rewrite Programming...Ch. 2 - (Physics: finding runway length) Given an...Ch. 2 - (Financial application: compound value) Suppose...Ch. 2 - (Health application: computing BMI) Body Mass...Ch. 2 - (Geometry: distance of two points) Write a program...Ch. 2 - (Geometry: area of a hexagon) Write a program that...Ch. 2 - (Science: wind-chill temperature) How cold is it...Ch. 2 - (Print a table) Write a program that displays the...Ch. 2 - (Geometry: area of a triangle) Write a program...Ch. 2 - (Financial application: calculate interest) If you...Ch. 2 - (Financial application: calculate future...Ch. 2 - (Financial application: monetary units) Rewrite...Ch. 2 - (Cost of driving) Write a program that prompts the...

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Program to find HCF & LCM of two numbers in C | #6 Coding Bytes; Author: FACE Prep;https://www.youtube.com/watch?v=mZA3cdalYN4;License: Standard YouTube License, CC-BY