Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

Describe the Big Five personality dimensions.

Answered: 1 week ago

Question

Identify three personal human relations goals for the course.

Answered: 1 week ago