1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
a_sh-v [17]
4 years ago
15

Hit and Slopes Program: A Write a program that can be used by a ski resort to keep track if local snow conditions for one week.

It should have two seven-element arrays to store the date and number of inches of snow (consider the parallel array concept discussed in the class). First, the program should ask the user to enter the name of the month. Then, it should have the user enter dates and corresponding snow fall. Once data is entered, store them in two arrays mentioned above. Then, the program should produce a report for the week with following information. a) Highest snow fall. b) Average snow fall.
Computers and Technology
1 answer:
Llana [10]4 years ago
5 0

Answer:

The java program is as follows.  

import java.lang.*;  

import java.util.Scanner;  

public class Main  

{  

//array declaration  

static int weekdays=7;  

static int[] snowfall_inch = new int[weekdays];  

static String[] snowfall_date = new String[weekdays];  

//variables to store average and maximum  

static double avg;  

static int max;  

public static void main(String[] args) {  

Scanner sc = new Scanner(System.in);  

System.out.print("Enter the month: ");  

String month = sc.next();  

for(int n=0; n<weekdays; n++)  

{  

System.out.print("\nEnter the date for day "+(n+1)+ ": ");  

snowfall_date[n] = sc.next();  

System.out.print("Enter the inches of snowfall for day "+(n+1) +": ");  

snowfall_inch[n] = sc.nextInt();  

avg = avg + snowfall_inch[n];  

}  

avg = avg/weekdays;  

System.out.printf("The average snowfall for the week is %.4f",avg);  

for(int n=0; n<weekdays-1; n++)  

{  

if(snowfall_inch[n] < snowfall_inch[n+1])  

max=snowfall_inch[n+1];  

}  

System.out.println("\nThe maximum snowfall for the week is "+max);  

}  

}  

OUTPUT  

Enter the date for day 2: 12-2-2019

Enter the inches of snowfall for day 2: 23  

Enter the date for day 3: 12-3-2019

Enter the inches of snowfall for day 3: 13  

Enter the date for day 4: 12-4-2019

Enter the inches of snowfall for day 4: 14  

Enter the date for day 5: 12-5-2019

Enter the inches of snowfall for day 5: 34  

Enter the date for day 6: 12-6-2019

Enter the inches of snowfall for day 6: 34  

Enter the date for day 7: 12-7-2019

Enter the inches of snowfall for day 7: 22

The average snowfall for the week is 21.7143  

The maximum snowfall for the week is 34  

Explanation:

1. Two arrays are declared to store dates and snowfall inches with string and integer datatypes respectively.  

2. Variables are declared to store maximum and average snowfall values with integer and double datatypes respectively.  

3. User input is taken for the month, and the dates and snowfall inch values for a week. The input is taken in for loop.  

4. Next, for loop is used to find the average and maximum snowfall of the week.  

5. These values are displayed to the user as shown in the output.

You might be interested in
True or false? (a) Main memory is volatile. (b) Main memory is accessed sequentially. (c) Disk memory is volatile. (d) Disk memo
allochka39001 [22]

Answer:

The answer to your question is true

5 0
3 years ago
25 points!!!!!!!!!!!!!!!!!!!!!
Wittaler [7]

Answer:

thank u appreciate it

Explanation:

4 0
3 years ago
Read 2 more answers
The best grounding method when arc welding is to connect the welding machine grounding cable to
Scorpion4ik [409]
The material you are welding other wise an arc will not be created 
5 0
3 years ago
Read 2 more answers
When there is a limited amount of a product, such as rare art or collectible
babunello [35]
C. Scarcity
This is because the word scarce means something is hard to come across or find and there is an insufficient amount for the demand
7 0
3 years ago
Ask the user to enter a number for red, green, and blue components of an RGB value. Test to make sure each value is between 0 an
olganol [36]

Answer:

  1. r = int(input("Enter a number for red channel: "))
  2. g = int(input("Enter a number for green channel: "))
  3. b = int(input("Enter a number for blue channel: "))  
  4. if(r < 0 or r >255):
  5.    print("Red number is not correct.")
  6. if(g < 0 or g >255):
  7.    print("Green number is not correct.")
  8. if(b < 0 or b >255):
  9.    print("Blue number is not correct.")

Explanation:

The solution code is written in Python.

Firstly, prompt user to input three numbers for red, green and blue (Line 1-3).

Next, create three similar if statements to check if the red, green and blue are within the range 0-255 by using logical operator "or" to check if the number is smaller than 0 or bigger than 255. If either one condition is met, display a message to indicate a particular color number is not correct (Line 5-12).

3 0
3 years ago
Other questions:
  • A _____ captures the pattern in a _____ and sends it to the computer, where special software translates the _____ into meaningfu
    8·1 answer
  • WILL MARK YOU BRAINLIEST :
    9·1 answer
  • Which of the following is the fastest way to open an Access database? a. Right-click the database icon. b. Start Access from the
    13·2 answers
  • A specialized storage device or group of storage devices that provides centralized fault-tolerant data storage for a network____
    13·1 answer
  • According to Ernest Hilgard, hypnosis is the result of __________.
    8·2 answers
  • Create a class called Book with the following properties using appropriate data types: Title, Author, numberOfPages, Create a se
    12·1 answer
  • Grace is performing a penetration test against a client's network and would like to use a tool to assist in automatically execut
    13·2 answers
  • Write a public static method diagSum, which takes a 2d array of int values as a parameter, and returns the sum of the elements i
    6·1 answer
  • You discover that the lecturers will be using the laptops for online and video lecturing, and you see the need to upgrade the RA
    5·2 answers
  • Define a function SwapRank() that takes two char parameters passed by reference and swap the values in the two parameters. The f
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!