Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

how can i separate this code in different int methods int method for time like this ----------------->( public static long getTestTime(starttime,endTime) { and method for

how can i separate this code in different int methods

int method for time like this ----------------->( public static long getTestTime(starttime,endTime) {

and method for level1

and create another method that makes level1 run only for 90 seconds and increase the total time by 5 seconds if 5 questions is correct

and create a two method one is asking the user if he wants to continue or wants to quite

JAVA java JAVA javaJAVA javaJAVA javaJAVA javaJAVA javaJAVA javaJAVA javaJAVA javaJAVA javaJAVA javaJAVA javaJAVA javaJAVA java

-------------------------------------------------------------------------------------------------------------------

package javaapplication108;

import java.util.Scanner;

/** * * @author Zainab */ public class JavaApplication108 {

/** * @param args the command line arguments */ public static void main(String[] args) { Scanner input = new Scanner(System.in);

int x, y, z;

int correctCount = 0; // Count the number of correct answers int count = 0; // Count the number of questions String output = ""; // output string is initially empty long starttime = System.currentTimeMillis();

while (count < 7) {

x = (int) (Math.random() * 10) + 10; y = (int) (Math.random() * 10) + 10; z = 0; int min = 0; int max = 4; // exclusive int num = (int) (Math.random() * (max - min) + min); char operator = ' ';

switch (num) { case 0: operator = '+'; z = x + y; break; case 1: operator = '-'; z = x - y;

break; case 2: operator = '*'; z = x * y;

break; case 3: operator = '/'; z = x / y;

break; default: operator = '?'; }

System.out.println(x + " " + operator + " " + y); System.out.println("....."); int val = input.nextInt(); if (z == val) { System.out.println("Correct"); correctCount++; } else { System.out.println("worng"); } count++; }

long endTime = System.currentTimeMillis(); long testTime = endTime - starttime;

System.out.println("Correct count is " + correctCount + " Test time is " + testTime / 1000 + " seconds " ); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 2 Lnai 6322

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215882X, 978-3642158827

More Books

Students also viewed these Databases questions