Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Convert from C# to Java Scanner: using System; public class Rainfall { public static void Main ( ) { / / declare variable and array
Convert from C# to Java Scanner:
using System;
public class Rainfall
public static void Main
declare variable and array
int choice ;
double rainfall new double;
for int x ; x ; x
rainfallx;
for int x ; x ; x
get rainfall amounts
Console.WriteEnter rainfall for month x ;
Console.Write: ;
rainfallx Convert.ToDoubleConsoleReadLine;
end for
do
display menu and get menu choice
Console.WriteLine;
Console.WriteLine Display monthly amounts";
Console.WriteLine Display total amount";
Console.WriteLine End program";
Console.WriteEnter your choice: ;
choice Convert.ToIntConsoleReadLine;
call appropriate function or end program
if choice
displayMonthlyrainfall;
else if choice
displayTotalrainfall;
end ifs
while choice choice ;
function definitions
public static void displayMonthlydouble rain
Console.WriteLineMonthly rainfall amounts:";
for int x ; x ; x
Console.WriteLinerainx;
end for
end of displayMonthly function
public static void displayTotaldouble rain
double total ;
for int x ; x ; x
total total rainx;
end for
Console.WriteLineTotal rainfall: total;
end of displayTotal function
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started