Concept explainers
In
Write a program that converts a temperature input in degrees Celsius into degrees Fahrenheit and displays both temperatures. You will need the following variables:
Celsius (a Float) Fahrenheit (a Float)
You will need the following formula:
Want to see the full answer?
Check out a sample textbook solutionChapter 1 Solutions
PRELUDE TO PROGRAMMING (LL) >CUSTOM<
Additional Engineering Textbook Solutions
C++ How to Program (10th Edition)
C Programming Language
Web Development and Design Foundations with HTML5 (8th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
C How to Program (8th Edition)
- Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as input, and output the gas cost for 20 miles, 75 miles, and 500 miles. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:System.out.printf("%.2f", yourValue); The output ends with a new line. Ex: If the input is: 20.0 3.1599 the output is: 3.16 11.85 79.00 For some reason my code is not functioning for all inputs to display the requested outputs. this is my code used: import java.util.Scanner; public class LabProgram {public static void main(String[] args) { Scanner sc = new Scanner(System.in);double n1 = sc.nextDouble();double n2 = sc.nextDouble();double product1 = n2*20/20;double product2 = n2*75/20;double product3 = n2*500/20;System.out.printf("%.2f %.2f %.2f",product1,product2,product3);System.out.println();}} this one is showing correctly: Input 20.0 3.1599 Your output 3.16 11.85 79.00 Expected output 3.16 11.85…arrow_forwardIn this question, you are required to write a program that takes as an input any decimal number (with fractional part) and then converts the fractional part to binary and display it on the screen. The program also takes in the number of fractional digits to show in the binary number (suppose this number could be entered and saved as floating-point, yet we test if it is integer or not later inside the program).Before converting the number, please take the following rules into consideration:• If the number to be converted has an integer part, the program should discard the integer part and convert the fractional part only.• If the number to be converted is negative then the program output should be Invalid.• If the number of required binary digits is not a positive integer, then the program output should be Invalid.There are several methods that can be used to perform the conversion task. Below, we will discuss two of these methods briefly and you have the freedom to use anyone of them…arrow_forwardDriving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as input, and output the gas cost for 20 miles, 75 miles, and 500 miles. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:System.out.printf("%.2f", yourValue); The output ends with a newline. Ex: If the input is: 20.0 3.1599 the output is: 3.16 11.85 79.00arrow_forward
- Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as input, and output the gas cost for 20 miles, 75 miles, and 500 miles. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:System.out.printf("%.2f", yourValue); The output ends with a newline. Ex: If the input is: 20.0 3.1599 the output is: 3.16 11.85 79.00 Note: Real per-mile cost would also include maintenance and depreciation.arrow_forward(in Python) Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 10 miles, 50 miles, and 400 miles. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:print('{:.2f}'.format(your_value)) Ex: If the input is: 20.0 3.1599 the output is: 1.58 7.90 63.20 Your program must define and call the following driving_cost() function. Given input parameters driven_miles, miles_per_gallon, and dollars_per_gallon, the function returns the dollar cost to drive those miles. Ex: If the function is called with: 50 20.0 3.1599 the function returns: 7.89975 def driving_cost(driven_miles, miles_per_gallon, dollars_per_gallon) Your program should call the function three times to determine the gas cost for 10 miles, 50 miles, and 400 miles.arrow_forwardHi, I need help with the following assignment. Implement a program that reads in a year and outputs the approximate value of a Ferrari 250 GTO in that year. Use the following table that describes the estimated value of a GTO at different times since 1962. Year Value 1962-1964 $18,500 1965-1968 $6,000 1969-1971 $12,000 1972-1975 $48,000 1976-1980 $200,000 1981-1985 $650,000 1986-2012 $35,000,000 2013-2014 $52,000,000arrow_forward
- For each unit conversion listed below,write a short program that prompts the user to enter a number, stores it in an appropriately named variable, performs the necessary calculations, and outputs the results to the screen with proper labels and two (2) decimal places.Write a separate program for each case.Name the program files as follows: Lab3a_Act1_a.py, Lab3a_Act1_b.py, and so on. a)Pounds(force)to Newtonsb)Kilometers to milesc)Atmospheres to millimeters of mercuryd)Wattsto BTU per houre)Liters per secondto gallons per minutef)Degrees Celsiusto degrees Rankinearrow_forwardDriving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as input, and output the gas cost for 20 miles, 75 miles, and 500 miles. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:System.out.printf("%.2f", yourValue); The output ends with a newline.arrow_forwardDriving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as input, and output the gas cost for 20 miles, 75 miles, and 500 miles. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:System.out.printf("%.2f", yourValue);arrow_forward
- I'm stuck on this problem, and here's what I'm stumped on: Meadowdale Dairy Farm sells organic brown eggs to consumers in the surrounding area. For a dozen eggs, it charges $3.25, and for individual eggs that are not part of a dozen, it charges 45 cents each egg. Using the following phrasing, write a program that prompts a user to enter the number of eggs in the order and then displays the amount owed along with a detailed explanation of why the amount is due: You placed an order for 27 eggs. There are 2 dozen eggs at $3.25 per dozen and 3 loose eggs at 45 cents each, which adds up to a total of $7.85.arrow_forwardDriving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 20 miles, 75 miles, and 500 miles. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:print('{:.2f} {:.2f} {:.2f}'.format(your_value1, your_value2, your_value3)) Ex: If the input is: 20.0 3.1599 Then the output is: 3.16 11.85 79.00 Note: Real per-mile cost would also include maintenance and depreciation.arrow_forwardThe program that you create for this exercise will begin by reading the cost of a meal ordered at a restaurant from the user. Then your program will compute the tax and tip for the meal. Use your local tax rate when computing the amount of tax owing. Compute the tip as 18 percent of the meal amount (without the tax). The output from your program should include the tax amount, the tip amount, and the grand total for the meal including both the tax and the tip. Format the output so that all the values are displayed usingtwo decimal places.arrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage