Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Revisit Assignment 2 (if you did not do Assignment 2, get the solution from the Assignments folder) and allow the user to enter the number

Revisit Assignment 2 (if you did not do Assignment 2, get the solution from the Assignments folder) and allow the user to enter the number of conversions to convert in one session from Fahrenheit to Celsius. Use a loop statement (while, do-while, or for) to enable multiple conversions in one session.

This is the Code for Assign2

import java.util.Scanner; public class Assignment2 { public static void main(String[] args) { float celsius,fahrenheit; Scanner keyboard=new Scanner(System.in); System.out.println("Please enter the temperature in Fahrenheit> "); fahrenheit = keyboard.nextFloat(); celsius = (fahrenheit-32)*5/9; System.out.printf("The corresponding temperature in Celsius is %.1f", celsius); } }.

First, validate the number of conversions to ensure it is a positive integer (> 0), if not, display the message Invalid number of conversions and terminate the program using System.exit(-1) (-1 indicates that the program terminated abnormally).

Here are 2 scenarios of how your program should behave (the underlined refers to data entered by the user):

Scenario 1:

Please enter the number of conversions> -9

Invalid number of conversions

Scenario 2:

Please enter the number of conversions> 4

Please enter the temperature in Fahrenheit> 41

The corresponding temperature in Celsius is 5.0

Please enter the temperature in Fahrenheit> 37.6

The corresponding temperature in Celsius is 3.1

Please enter the temperature in Fahrenheit> 90.5

The corresponding temperature in Celsius is 32.5

Please enter the temperature in Fahrenheit> 120.7

The corresponding temperature in Celsius is 49.3

As shown in Scenario 2 above, since the user entered 4, we allowed him/her to perform 4 conversions. Please note that your program should work for any postitive number of conversions (not only for 4) and without modifying the program.

Can you take a screenshot of the output and the stdin and could you possibly type the new code so i can copy it and paste it to my compiler,

Thanks

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

How do members envision the ideal team?

Answered: 1 week ago

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago