Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
