em có chuơng trình như vậy, khi chạy chuơng trình thì nó hiện ra 1 menu lựa chọn và cho mình chọn các mục tuơng ứng,vấn đề của em là làm sao để khi ta chạy 1 cái danh sách trong menu đó và hiển thị câu hỏi để mình trả lời, khi trả lời xong chuơng trình lại quay lại menu và cho chọn các mục tiếp theo...và làm sao để khi nó chạy 1 cái danh sách rồi thì khi nó quay lại cái menu thì ko thể chọn được cái danh sách mình đã chọn trước đó...nhờ mọi người giúp giùm với ah( vd : em chọn mục Aptibude và trả lời câu hỏi-->khi nó chạy ra menu thì sẽ ko đc chọn mục Aptibude này nữa làm ntn ah...mong chỉ giùm )
Mã:
package demolop;
import java.util.Scanner;
public class AssignmentB3 {
public static void main(String[] args) {
int score = 0;
int choose =0;
boolean b1 = false;
boolean b2 = false;
boolean b3 = false;
boolean b4 = false;
boolean isExit = true;
while(isExit){
Scanner s = new Scanner(System.in);
System.out.println ("1.Aptibude");
System.out.println ("2.English");
System.out.println ("3.Math");
System.out.println ("4.GK");
System.out.println ("5.Exit");
System.out.print("please you are choose (1-5) :");
choose = s.nextInt();
switch(choose)
{
case 1 :
System.out.println("choose 1 in 2 Question ");
System.out.println("1.1+1=?");
System.out.println("1+2=?");
System.out.print("your result = ");
int r1 = s.nextInt();
b1=true;
if(r1==1){
score+=10;
}break;
case 2 : System.out.println("choose 1 in 2 Question ");
System.out.println("1.1+1=?");
System.out.println("1+2=?");
System.out.print("your result = ");
int r2 = s.nextInt();
b2=true;
if(r2==1){
score+=10;
}break;
case 3 :System.out.println("choose 1 in 2 Question ");
System.out.println("1.1+1=?");
System.out.println("1+2=?");
System.out.print("your result = ");
int r3 = s.nextInt();
b3=true;
if(r3==1){
score+=10;
}break;
case 4 :System.out.println("choose 1 in 2 Question ");
System.out.println("1.1+1=?");
System.out.println("1+2=?");
System.out.print("your result = ");
int r4 = s.nextInt();
b4=true;
if(r4==1){
score+=10;
}break;
}
if(choose == 5 && b1 & b2 & b3 & b4 ){
isExit=false;
}
}
System.out.println("total score is : "+score);
int bonusPoint = 0;
switch(score){
case 10 : bonusPoint = 0; break;
case 20 : bonusPoint = 2; break;
case 30 : bonusPoint = 5; break;
case 40 : bonusPoint = 10; break;
}
int finalScore = score+bonusPoint;
switch(finalScore){
case 10 : System.out.println("Your IQ level is bellow average "); break;
case 22 : System.out.println("Your IQ level is average");
case 35 : System.out.println("You are intelligent");
case 40 : System.out.println("You are a Genius");
case 0 : System.out.println("You need to re-appear the test");
}
}
}
:down:
Bạn đang tìm kiếm giải pháp vận chuyển và nâng hạ hàng hoá máy móc nặng cho dự án hay công việc của mình tại khu vực Mỹ Phước - Bình Dương? Chúng tôi tự hào giới thiệu dịch vụ cho thuê xe cẩu tại Mỹ...
Dịch vụ cho thuê xe cẩu tại Mỹ Phước từ 3 tấn 120 tấn