Question

In: Computer Science

IN JAVA Create a program that asks the user to input the day, high and low...

IN JAVA

Create a program that asks the user to input the day, high and low temperature. Display the day, high, and low. Use a While Loop to enter all seven days of the week and high temperatures. Inside the While Loop, the program will count, total, and average the highs. The following will be displayed:

                        Day: (variable)

                        High: (variable)

                        Count High: (variable)

                        Total High: (variable)

                        Average High: (variable)

After the seven days and highs have been entered and displayed, use a For Loop to prompt the user for the days and the low temperatures. Inside the For Loop, the program will count, total, and average the lows. The following will be displayed:

                        Day: (variable)

                        Low: (variable)

                        Count Low: (variable)

                        Total Low: (variable)

                        Average Low: (variable)

Use a Do-While Loop to prompt the user to input the days, highs and lows. The program will count, total, and average the highs, and count, total, and average the lows. Display the following:

                        Day: (variable)

                        High: (variable)

                        Count High: (variable)

                        Total High: (variable)

                        Average High: (variable)

                        Day: (variable)

                        Low: (variable)

                        Count Low: (variable)

                        Total Low: (variable)

                        Average Low: (variable)

Prompt the user if they want to continue with another entry. If “Yes”, the DO-While repeats. If “No”, the program will end.

Solutions

Expert Solution

import java.util.*;
public class Main{

     public static void main(String []args){
         int i=0,High,Count_High=0,Total_High=0,Average_High=0,low,Count_low=99,Total_low=0,Average_low=0;
         String Day,flag;
       Scanner sc = new Scanner(System.in);
      while(i<7)
      {
          System.out.println("Enter day"+i);
          Day = sc.next();
          System.out.println("Enter Highest temp of day"+i);
          High = sc.nextInt();
          if(High>Count_High)
            Count_High=High;
          Total_High+=High;
          i++;
      }
      Average_High=Total_High/7;
      System.out.println(Count_High+" "+Total_High+" "+Average_High);
       
      for(i=0;i<7;i++)
      {
          System.out.println("Enter day"+i);
          Day = sc.next();
          System.out.println("Enter low temp of day"+i);
          low = sc.nextInt();
          if(low<Count_low)
            Count_low=low;
          Total_low+=low;
      }
      Average_low=Total_low/7;
      System.out.println(Count_low+" "+Total_low+" "+Average_low);
       
       do{
           System.out.println("Do you want to play");
           flag = sc.next();
           if(flag =="No")
                break;
            else
            {
                  System.out.println("Enter day"+i);
                  Day = sc.next();
                  System.out.println("Enter Highest temp of day"+i);
                  High = sc.nextInt();
                  if(High>Count_High)
                    Count_High=High;
                  Total_High+=High;
                  
                  System.out.println("Enter day"+i);
                  Day = sc.next();
                  System.out.println("Enter low temp of day"+i);
                  low = sc.nextInt();
                  if(low<Count_low)
                    Count_low=low;
                  Total_low+=low;
                  i++;
            }
       }while(i<7);
       Average_High=Total_High/7;
      System.out.println(Count_High+" "+Total_High+" "+Average_High);
       Average_low=Total_low/7;
      System.out.println(Count_low+" "+Total_low+" "+Average_low);
     }
}

Related Solutions

IN JAVA Create a program that asks the user to input the day, high and low...
IN JAVA Create a program that asks the user to input the day, high and low temperature. Display the day, high, and low. Use a While Loop to enter all seven days of the week and high temperatures. Inside the While Loop, the program will count, total, and average the highs. The following will be displayed:                         Day: (variable)                         High: (variable)                         Count High: (variable)                         Total High: (variable)                         Average High: (variable) After the seven days and highs...
Write Java program that asks a user to input a letter, converts the user input to...
Write Java program that asks a user to input a letter, converts the user input to uppercase if the user types the letter in lowercase, and based on the letter the user the user enters, display a message showing the number that matches the letter entered. For letters A or B or C display 2 For letter D or E or F display 3 For letter G or H or I display 4 For letter J or K or L...
(JAVA) Create a program that prompts the user for an age input. The program defines the...
(JAVA) Create a program that prompts the user for an age input. The program defines the age group of the user. Follow the table below to construct the output for your program. Age Age Group 0 Baby 1-3 Toddler 4-11 Child 12-17 Teenager 18-21 Young Adult 22-64 Adult 65+ Senior Negative Number Invalid Input Sample Input Enter an age: 18 Sample Output: You are a young adult. Sample Input Enter an age: 29 Sample Output: You are an adult. Sample...
Using C++ Create a program that asks the user to input a string value and then...
Using C++ Create a program that asks the user to input a string value and then outputs the string in the Pig Latin form. - If the string begins with a vowel, add the string "-way" at the end of the string. For “eye”, it will be “eye-way”. - If the string does not begin with a vowel, first add "-" at the end of the string. Then rotate the string one character at a time; that is, move the...
Create a program that asks the user to input three numbers and computes their sum. This...
Create a program that asks the user to input three numbers and computes their sum. This sounds simple, but there's a constraint. You should only use two variables and use combined statements. You can use the output below as a guide. Please enter the first number: 4 Please enter the second number: 2 Please enter the third number: 9 The sum of the three numbers is: 15.
Create a Java program that asks a user to enter two file names. The program will...
Create a Java program that asks a user to enter two file names. The program will read in two files and do a matrix multiplication. Check to make sure the files exist. first input is the name of the first file and it has 2 (length) 4 5 6 7 Second input is the name of the second file and it has 2 (length) 6 7 8 9 try catch method
1. Write a Java program that asks the user to input a positive integer n first,...
1. Write a Java program that asks the user to input a positive integer n first, then create an array of size n. Fill n random integers between 5 and 555, inclusively, into the created array. Output the sum of all the integers in the array and the average of all the integers in the array. 2 .Find the output of the following Java program and explain your answer
This is Java In this problem we will write a program that asks the user to...
This is Java In this problem we will write a program that asks the user to enter a) The user's first name and b) a series of integers separated by commas. The integers may not include decimal points nor commas. The full string of numbers and commas will not include spaces either, just digits and commas. An example of valid input string is:        7,9,10,2,18,6 The string must be input by the user all at once; do not use a loop...
In Java:Implement a program that repeatedly asks the user to input apositive integer and...
In Java:Implement a program that repeatedly asks the user to input a positive integer and outputs the factorial of that input integer. Do not use recursion, solution should use stack.
Write a simple MIPS program that asks the user to input a string and then a...
Write a simple MIPS program that asks the user to input a string and then a character. The program should then count how many times that character appears in the string and print out that value. Please use comments.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT