Question: Modify Snowfall - write a code that finds the cities with the lowest and highest snowfall amounts. import java.util.Scanner; public class JLynch { public static

Modify Snowfall - write a code that finds the cities with the lowest and highest snowfall amounts. import java.util.Scanner;
public class JLynch {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
String[] cities = new String[4];
int[] snowfalls = new int[4];
double totalSnowfall =0;
double avgsnowfall;
// Input city names and snowfall amounts
for (int i =0; i <4; i++){
System.out.println("Enter city name: ");
cities[i]= scanner.nextLine();
System.out.println("Enter snowfall amount (in inches) for "+ cities[i]+": ");
snowfalls[i]= scanner.nextInt();
scanner.nextLine(); // to handle the newline character
}
// Display city names and snowfall amounts
System.out.println("
Snowfall amounts:");
for (int i =0; i <4; i++){
System.out.println(cities[i]+": "+ snowfalls[i]+" inches");
totalSnowfall += snowfalls[i];
}
// Compute the average snowfall
avgsnowfall = totalSnowfall/4;
System.out.println("Total Snowfall "+ totalSnowfall +" inches");
System.out.println("Average Snowfall "+ avgsnowfall +" inches");
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!