In Java. I am getting confused with this assignment, my confusion starts where I stopped.
Create a package named temperature and create a program that has a while loop.
• Inside the while loop, your program will prompt the user for temperature in Centigrade.
• If the Centigrade value read in is <= -100, the loop will exit.
• Otherwise, your program will compute the Fahrenheit equivalent temperature.
• Inside the while loop, your program will print out the Centigrade and Fahrenheit temperatures. • Keep a count of the valid user inputs and a running total of your Fahrenheit and Centigrade temperatures.
• When the user terminates the while loop, print out the average Centigrade and Fahrenheit temperatures.
• Note that o Average_Fahrenheit = Total_of_Fahrenheit/ total_user_inputs o Average_Centigrade = Total_of_Centigrade / total_use_inputs
• Also note that: o Fahrenheit = (9.0/5.0)*Centigrade + 32.0
************************ Here is some sample output from your program: ***************************
Enter Temp in Centigrade or <= -100.0 to quit: 20 Temperature: F(68.0) C(20.0)
Enter Temp in Centigrade or <= -100.0 to quit: 30
Temperature: F(86.0) C(30.0)
Enter Temp in Centigrade or <= -100.0 to quit: 40
Temperature: F(104.0) C(40.0)
Enter Temp in Centigrade or <= -100.0 to quit: 1
Temperature: F(33.8) C(1.0) Enter Temp in Centigrade or <= -100.0 to quit: -10
Temperature: F(14.0) C(-10.0) Enter Temp in Centigrade or <= -100.0 to quit: -100 Average: Centigrade(16.2)
Average: Fahrenheit(61.160000000000004)
This is what I have started with, where the coding stops is where I am lost.
package temperature;
import java.util.Scanner;
public class Temperature {
public static void main(String[] args) {
Scanner userInput = new
Scanner(System.in);
double celsius, Centigrade,
averageFahrenheit, averageCentigrade, totalUserInput = 0;
do {
System.out.println("Enter Temp in Centigrade or <=
-100.0 to quit: ");
celsius = userInput.nextDouble();
double fahrenheit = (9.0/5.0)*Centigrade +32.0;
}
}
}
//Java program
import java.util.Scanner;
public class Temperature {
public static void main(String[] args) {
Scanner userInput = new Scanner(System.in);
double celsius, fahrenheit, averageFahrenheit, averageCentigrade,
totalUserInput = 0;
double totalFahrenheit=0, totalCentigrade=0;
do {
System.out.print("Enter Temp in
Centigrade or <= -100.0 to quit: ");
celsius = userInput.nextDouble();
if(celsius>-100) {
totalUserInput++;
fahrenheit =
(9.0/5.0)*celsius +32.0;
System.out.printf("Temperature : F(%.1f) C(%.1f)\n",
fahrenheit,celsius);
totalFahrenheit+=fahrenheit;
totalCentigrade+=celsius;}
}while(celsius>-100);
if(totalUserInput>0) {
averageFahrenheit =
totalFahrenheit/totalUserInput;
averageCentigrade =
totalCentigrade/totalUserInput;
}
else {
averageFahrenheit=0;
averageCentigrade=0;
}
System.out.printf("Average:
Centigrade:(%.1f)\n", averageCentigrade);
System.out.printf("Average:
Fahrenheit:(%.1f)\n", averageFahrenheit);
userInput.close();
}
}
//sample output
In Java. I am getting confused with this assignment, my confusion starts where I stopped. Create a package named tempera...
in Java, temperature problem Create a package named temperature and create a program that has a while loop. • • Inside the while loop, your program will prompt the user for temperature in Centigrade. If the Centigrade value read in is <= -100. the loop will exit. Otherwise, your program will compute the Fahrenheit equivalent temperature. Inside the while loop, your program will print out the Centigrade and Fahrenheit temperatures. Keep a count of the valid user inputs and a...
CIST 1305 – Program Design and Development Chapter 4 Assignment #7 [Decisions/If Statements & Loops] (50 Points) Please do the following exercises: Pastoral College is a small college in the Midwest. Design the pseudo-code for a program that accepts a student name, major field of study, and grade point average. Display a student’s data with the message “Dean’s list” if the student’s grade point average is above 3.5, “Academic probation” if the grade point average is below 2.0, and no...
I need help with the following assignment: Write an application named DailyTemps that continuously prompts a user for a series of daily high temperatures until the user enters a sentinel value of 999. Valid temperatures range from -20 through 130 Fahrenheit. When the user enters a valid temperature, add it to a total; when the user enters an invalid temperature, display the error message: Valid temperatures range from -20 to 130. Please reenter temperature. Before the program ends, display the...
package _solution; /** This program demonstrates how numeric types and operators behave in Java Do Task #1 before adding Task#2 where indicated. */ public class NumericTypesOriginal { public static void main (String [] args) { //TASK #2 Create a Scanner object here //identifier declarations final int NUMBER = 2 ; // number of scores int score1 = 100; // first test score int score2 = 95; // second test score final int BOILING_IN_F = 212; // boiling temperature double fToC;...
using C Process Create a City structure. The structure will hold the name of a city and its temperature. In the main function, read in a series of city names and their temperature expressed in Fahrenheit. Store the data in an array of City structures. Stop reading when either: The user enters the word "quit" for a city name, or The size of the array is about to be exceeded. Create a function that determines the highest temperature of the...
I need help on creating a while loop for my Java assignment. I am tasked to create a guessing game with numbers 1-10. I am stuck on creating a code where in I have to ask the user if they want to play again. This is the code I have: package journal3c; import java.util.Scanner; import java.util.Random; public class Journal3C { public static void main(String[] args) { Scanner in = new Scanner(System.in); Random rnd = new Random(); System.out.println("Guess a number between...
C# I am having trouble this program. So far my temperature converter program is converting temps from C to F. However, whenever I try to convert F to C, it's keep crashing and displaying an error message, which I can not figure it out and do not know how to fix it. Attached are two screenshots are of message. Do you know what is causing the issue? I would much appreciate your assistance. namespace Temp Conv { public partial class...
The following is a program from Starting out with C++ by Toni Gaddis. I am getting the following error messages pertaining to the lines: cin>>month[i].lowTemp; and months[i].avgTemp = (months[i].highTemp + month[i].lowTemp)/2; The error messages read as follows: error C2039: 'lowTemp': is not a member of 'std::basic_string<_Elem,_Traits,_Ax>' and it continues. The second error message is identical. The program is as follows: Ch. 11, Assignment #3. pg. 646. Program #4. //Weather Statistics. //Write a program that uses a structure to store the...
Hi I need help with a java program that I need to create a Airline Reservation System I already finish it but it doesnt work can someone please help me I would be delighted it doesnt show the available seats when running the program and I need it to run until someone says no for booking a seat and if they want to cancel a seat it should ask the user to cancel a seat or continue booking also it...
Your assignment is to create a restaurant ordering system where the cashier can create the menu and then take in the order and display the order back to the customer Sample Execution – Level 1 Welcome to your Menu Creation system. How many items would you like to have on your menu? 2 Create your menu! Enter item #1: Coffee Enter item #2: Tea This is the menu: Coffee Tea What would you like to order? Cake That isn’t on...