Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package lab6_5;
- /**
- *
- * @author Nyeh
- */
- import java.util.Random;
- import java.util.Scanner;
- public class Lab6_5 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- Scanner in=new Scanner(System.in);
- Random r=new Random();
- //the two random value
- int ans;
- int x,y;
- int count=0;
- System.out.println("Enter negative number to quit.");
- x=r.nextInt(13);
- y=r.nextInt(13);
- System.out.print(x+" x "+y+" = ");
- ans=in.nextInt();
- if(compare(x,y,ans))
- count++;
- while(ans>=0){
- System.out.println("Enter negative number to quit.");
- x=r.nextInt(13);
- y=r.nextInt(13);
- System.out.print(x+" x "+y+" = ");
- ans=in.nextInt();
- if(compare(x,y,ans))
- count++;
- }
- System.out.println("Your Score is :"+count);
- }
- public static boolean compare(int a,int b,int c)
- {
- if(a*b==c)
- return true;
- else
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement