You are Here: Home >< GCSEs

# Computer Science watch

1. please can someone fix this or correct me on my commenting its good to help me grow as a coder

import java.util.Scanner;
import java.io.*; //Imports either a * - +
import java.util.Random; //Imports random numbers

public class Qu1 {
public static void main(String[] args) {
// TODO Auto-generated method stub

Scanner input = new Scanner(System.in);
Random Number = new Random();
String name = input.next(); //This stores the name

int CCounter = 0; //Variable for the counter
int Counter = 0;

do { //This asks the code to do the run the following code

int a = Number.nextInt(10); //Two random numbers are created using the import.util.Random, the highest the numbers can go to is ten shown by the (10)
int b = Number.nextInt(10);

Random Digit = new Random();
int d = Digit.nextInt(3);
if (d == 0) {
System.out.println(Counter + 1 + "." + " What is " + a +
"+" + b);
int answer = a + b;
int x = input.nextInt();
if (x == (a + b)) {
System.out.println("Correct!");
CCounter = CCounter + 1;
Counter = Counter + 1;
System.out.println("Mark: " + CCounter + "/" + Counter);
}
else {
Counter = Counter + 1;
System.out.println("You have " + CCounter + "/" +
Counter);
}
}
// - Sums
else if (d == 1) {
System.out.println(Counter + 1 + "." + " What is " + a +
"-" + b);
int answer = a - b;
int x = input.nextInt();
if (x == (a - b)) {
System.out.println("Correct!");
CCounter = CCounter + 1;
Counter = Counter + 1;
System.out.println("Mark: " + CCounter + "/" + Counter);
}
else {
Counter = Counter + 1;
System.out.println("You have " + CCounter + "/" +
Counter);
}
// * Sum
}
else if (d == 2) {
System.out.println(Counter + 1 + "." + " What is " + a +
"*" + b);
int answer = a * b;
int x = input.nextInt();
if (x == (a * b)) {
System.out.println("Correct!");
CCounter = CCounter + 1;
Counter = Counter + 1;
System.out.println("Mark: " + CCounter + "/" + Counter);
}
else {
}
while (Counter < 10);
if (CCounter == 10) {
System.out.println("Well Done " + name +
" you got 100%!");
}
else {
System.out.println("Well done " + name +
" you percentage is: " + CCounter + "0%");
File file = new File("N://Results.txt");
try {
PrintWriter output = new PrintWriter(file);
output.println(name);
output.println("Score- " + CCounter + "0%");
output.close();
}
catch (IOException ex) {
System.out.printf("ERROR: %s\n", ex);
}
}
}
2. Please consider taking this down as people will plagiarize you.

TSR Support Team

We have a brilliant team of more than 60 Support Team members looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

This forum is supported by:
Updated: March 21, 2016
Today on TSR

### A-Level OCR Biology Unofficial Markscheme

Find out how you've done here

### 2,862

students online now

Exam discussions

Poll
Useful resources

## Study tools

### Essay expert

Learn to write like a pro with our ultimate essay guide.

See where you can apply with our uni match tool

### Make study resources

Create all the resources you need to get the grades.

### Create your own Study Plan

Organise all your homework and exams so you never miss another deadline.

### Resources by subject

From flashcards to mind maps; there's everything you need for all of your GCSE subjects.

### Find past papers

100s of GCSE past papers for all your subjects at your fingertips.