ends in zero! eep going... imme a number: 53 ends in three! eep going... imme a number: 41 orry Charlie! You lose th imme a number: 50 ends in zero! eep going... imme a number: 23 =ends in three!
WRITE THE FOLLOWING PROGRAM IN HIGH LEVEL ASSEMBLY LANGUAGE (HLA)
import java.util.*;
class HelloWorld {
public static void main(String[] args) {
boolean flag=true;
int count = 0;
Scanner sc=new Scanner(System.in);
do{
System.out.print("Gimme a number: ");
int num=sc.nextInt();
if (num%10 ==0){
System.out.println("It ends with 0.\nKeep going\n");
count++;
}
else if (num%10 ==3){
System.out.println("It ends with 3.\nKeep going\n");
count++;
}
else{
flag=false;
System.out.print("Sorry Charlie. You loose the game.");
}
if(count==3){
System.out.print("You win the game.");
break;
}
}while(flag==true);
}
}
Step by step
Solved in 2 steps