What's new

Closed Mini multiplication game

Status
Not open for further replies.

Princess Serrano

Eternal Poster
Joined
Apr 2, 2016
Posts
429
Reaction
285
Points
285
Multiplication mini game. Have a try :)


import java.util.*;

public class Main
{
public static void main(String[] args)
{

Scanner Princess = new Scanner ( System.in ) ;

int level = 1 ;
int hard = 10 ;
int hard1 = 10 ;

while ( true ) {
int answer = 0 ;
int wrong = 0 ;
int score = 0 ;
String uncorrect = "" ;

System.out.println ( "\nLevel -->> "+level+" << -- \nWelcome to the multiplication Quiz.\n" ) ;

for ( int a = 0 ; a < 10 ; a ++ ) {
int ranDom1 = new Random ( ) . nextInt ( hard ) ;
int ranDom2 = new Random ( ) . nextInt ( hard1 ) ;
System.out.print ( ( a + 1 ) + ".) " + ranDom1 + " * " + ranDom2 ) ;
while ( true ) {
System.out.print ( "\tAnswer: " ) ;

if ( !Princess.hasNextInt ( ) ) {
System.out.println ( "Input an integer." ) ;
Princess.next ( ) ;
} else {
answer = Princess.nextInt ( ) ;
break ;
}
}

if ( ranDom1 * ranDom2 != answer ) {
uncorrect += " #" + ( a+1 );
wrong++ ;
} else {
}
}

score = ( 3 * ( 10 - wrong ) ) + 70 ;

hard += score / 40 ;
hard1 += score / 20 ;

System.out.println ( "\nGrade Percentage: " +score+ "% | " + ( 10 - wrong ) + "/10 " ) ;
System.out.println ( score == 100 ? "Perfect." : "Mistake:" +uncorrect ) ;
level ++ ;
}

}
}
 
Status
Not open for further replies.

Similar threads

Back
Top