Question : Write the pseudocode for the JAVA program below import java.util.Scanner; public class covidtest { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String...


Question : Write the pseudocode for the JAVA program below




import java.util.Scanner;
public class covidtest
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
String State, zone; //declare and input district
int districtno, sumcases = 0, totalcases = 0, average = 0;


//ask for all information needed from user//
System.out.print("Enter no of district in the state : "); //ask user for total number of district of the state given by user earlier
districtno = sc.nextInt();
System.out.print("Enter "+ districtno + " name of district in state : "); //ask user for name of districts in the state given
String[] name = new String[districtno];


for (int i = 0; i < name.length;="">
{
name[i] = sc.next();
}


System.out.print("Enter "+ districtno + " first total cases reading : "); //ask user for the first total cases reading
int[] firsttotal = new int[districtno];


for (int i = 0; i < firsttotal.length;="">
{
firsttotal[i] = sc.nextInt();
}


System.out.print("Enter "+ districtno + " second total cases reading : "); //ask user for the second total cases reading
int[] secondtotal = new int[districtno];


for (int i = 0; i < secondtotal.length;="">
{
secondtotal[i] = sc.nextInt();
}


System.out.print("\n");
System.out.print("\t\t**************************************");
System.out.print("\n");
System.out.print("\n");
System.out.print("\n");
System.out.print("\n");
System.out.print("\n");
System.out.print("\t\tList of district : \n");


for (int i = 0; i < name.length;="">
{
System.out.print("\t\t" + name[i]); //list out the district name for user
}


//display to user the first total reading given by user//
System.out.print("\n");

for (int i = 0; i < firsttotal.length;="">
{
System.out.print("\t\t"+ firsttotal[i] + "\t");
}


//display to user the second total reading given by user//
System.out.print("\n");

for (int i = 0; i < secondtotal.length;="">
{
System.out.print("\t\t"+ secondtotal[i] + "\t");
}




//display total for each district of both first and second readings//
System.out.print("\n");

int[] newtotalcases = new int [districtno];

for (int i = 0; i < districtno;="">

{
totalcases = firsttotal[i] + secondtotal[i]; //calculate total cases of first and second
newtotalcases[i] = totalcases;
System.out.print("\t\t"+ totalcases + "\t");
}


//find average for first and second total readings obtained//
System.out.print("\n");

for (int i = 0; i < districtno;="">
{
sumcases = sumcases + firsttotal[i] + secondtotal[i]; //calculate the average of total cases based on first and second total
average = sumcases / districtno;
}
System.out.print("\n\t\tAverage cases for today is: "+ average);


System.out.print("\n\n");


//determine cluster//
String remarks, zone1 = "Green Zone", zone2 = "Yellow Zone", zone3 = "cluster";
if (totalcases <>
{
remarks = zone1;
}
else if (totalcases > 10 && totalcases <>
{
remarks = zone2;
}
else

{
remarks = zone3;
}




int cluster = 0; //find the total cluster
for (int i = 0; i < districtno;="">
{
if (newtotalcases[i] <>
{
remarks = zone1;
}
if (newtotalcases[i] >= 10 && totalcases <=>
{
remarks = zone2;
}


if (newtotalcases[i] > 30)

{
cluster = cluster + 1;
remarks = zone3;
}
}


System.out.print("\t\tTotal cluster for today: "+ cluster);


System.out.print("\n\t\tFinal report of Covid-19 cases today: ");


System.out.print("\n\n");
System.out.print("\t\tdistrict\ttotal cases\tremarks");


//display name district, total cases, remarks
for (int i = 0; i < districtno;="">
{
totalcases = firsttotal[i] + secondtotal[i];
newtotalcases[i]= totalcases;


if (newtotalcases[i] <>
{
remarks = zone1;
}


if (newtotalcases[i] >= 10 && newtotalcases[i] <=>
{
remarks = zone2;
}


if (newtotalcases[i] > 30)

{
remarks = zone3;
}


System.out.print("\n\t\t"+ name[i] +"\t\t"+ newtotalcases[i] +"\t\t"+ remarks);
}




//determine the highest cases and its district name//
int highestcases = 0;

String highestdistrict = "";
for (int i = 0; i < districtno;="">
{
totalcases = firsttotal[i] + secondtotal[i]; //sum the first and second total cases for each district before comparing



if (totalcases > highestcases) //compare sum of each district obtained to each other to get the highest number of cases
{
highestcases = totalcases;
highestdistrict = name[i];

}
}


System.out.print("\n\n");

System.out.print("\t\tHighest cases for Covid-19 today: "+ highestcases); //display to user the highest number of cases
System.out.print("\n");
System.out.print("\t\tDistrict: "+highestdistrict); //display to user the district of the highest number of cases

}

}

Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here