import java.util.Scanner; import java.text.; public class Ave.pdf
anitasahani11
5 views
2 slides
Apr 08, 2023
Slide 1 of 2
1
2
About This Presentation
import java.util.Scanner;
import java.text.*;
public class AverageRainfall {
public static void main(String[] args) {
int years; // Variable to hold the amount of years
final int MONTHS = 12; // Constant to hold the amount of months in a year
int totalMonths = 0; // Months accumulator variable
doubl...
import java.util.Scanner;
import java.text.*;
public class AverageRainfall {
public static void main(String[] args) {
int years; // Variable to hold the amount of years
final int MONTHS = 12; // Constant to hold the amount of months in a year
int totalMonths = 0; // Months accumulator variable
double monthlyRain; // Holds the amount of rain in inches for each month
double totalRainfall = 0; // Holds the total rainfall
NumberFormat df = DecimalFormat.getInstance(); // Decimal formating
df.setMaximumFractionDigits(2);
// Create Scanner object
Scanner input = new Scanner(System.in);
// Prompt user for the number of years
System.out.println(\"Enter the number of years: \");
years = input.nextInt();
System.out.println(\"Enter the rainfall amount for each month \");
// Construct for-loop for each year
for(int i=0; i < years; i++){
for(int j=1; j
Solution
import java.util.Scanner;
import java.text.*;
public class AverageRainfall {
public static void main(String[] args) {
int years; // Variable to hold the amount of years
final int MONTHS = 12; // Constant to hold the amount of months in a year
int totalMonths = 0; // Months accumulator variable
double monthlyRain; // Holds the amount of rain in inches for each month
double totalRainfall = 0; // Holds the total rainfall
NumberFormat df = DecimalFormat.getInstance(); // Decimal formating
df.setMaximumFractionDigits(2);
// Create Scanner object
Scanner input = new Scanner(System.in);
// Prompt user for the number of years
System.out.println(\"Enter the number of years: \");
years = input.nextInt();
System.out.println(\"Enter the rainfall amount for each month \");
// Construct for-loop for each year
for(int i=0; i < years; i++){
for(int j=1; j.
Size: 25.07 KB
Language: en
Added: Apr 08, 2023
Slides: 2 pages
Slide Content
import java.util.Scanner;
import java.text.*;
public class AverageRainfall {
public static void main(String[] args) {
int years; // Variable to hold the amount of years
final int MONTHS = 12; // Constant to hold the amount of months in a year
int totalMonths = 0; // Months accumulator variable
double monthlyRain; // Holds the amount of rain in inches for each month
double totalRainfall = 0; // Holds the total rainfall
// Create Scanner object
Scanner input = new Scanner(System.in);
// Prompt user for the number of years
System.out.println(\"Enter the number of years: \");
years = input.nextInt();
System.out.println(\"Enter the rainfall amount for each month \");
// Construct for-loop for each year
for(int i=0; i < years; i++){
for(int j=1; j
Solution
import java.util.Scanner;
import java.text.*;
public class AverageRainfall {
public static void main(String[] args) {
int years; // Variable to hold the amount of years
final int MONTHS = 12; // Constant to hold the amount of months in a year
int totalMonths = 0; // Months accumulator variable
double monthlyRain; // Holds the amount of rain in inches for each month
double totalRainfall = 0; // Holds the total rainfall