convert this code to pseudo code import java.util.*; public class MAINCLASS { pu
ID: 3862162 • Letter: C
Question
convert this code to pseudo code
import java.util.*;
public class MAINCLASS {
public static void main(String[] args) {
Scanner keyboard=new Scanner(System.in);
int option;
do{
System.out.print("Add a number between 1 - 5 : ");
option=keyboard.nextInt();
if (option<1 || option>5)
{
System.out.println("You enterd invalid number. Please "+
"try again! ");
}
}
while(option<1 || option>5);
for( int i = 0 ; i < option ; i++ ){
System.out.print("Enter a number: ");
int getInput = keyboard.nextInt();
if (getInput == 0)
{
System.out.println("Erorr ");
}
else{
int max = getInput;
int min = getInput;
while(getInput != 0){
if (max < getInput)
{
max = getInput;
}
if (min > getInput)
{
min = getInput;
}
System.out.print("Enter a number: ");
getInput = keyboard.nextInt();
}
System.out.println("Max = "+ max);
System.out.println("Min = "+ min);
}
}
System.out.println("End Of Peogram");
}
}
Explanation / Answer
pseudocode:
i)importing java util pacakage
ii)creating class called MAINCLASS
i))defining main method
1)creating object Scanner class and reference name is keyboard
2)decalaring variable i of type integer
3) do while loop
i) add a number betweeb 1-5
ii)assign value to the vairable option
iii)if condition (option<1 or option>5) then you enter invalid number please try agian
iv)ending of do while loop with condition(option<1 or option>5)
4)starting for loop
i) enter a number
ii)decalring and assiging variable getInput of type integer
iii)if condition (getinput==0)
i)print statement
iv)else assign max and min values
i)while getinput not equal to 0
1)if max lessthan get input assign max is getinput
2)if min greater than getinputssign min is getinput
3)prints enter anumber
4)assigning getinput varible
v)print max and min
5) prints end of the program
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.