comp

?
  • Created by: 13martinl
  • Created on: 06-11-17 10:30

How do you declare scanners?

import java.io.*;

import java.util.Scanner;

1 of 16

How do you declare the topic class?

underneath

public class quizone{

write:

public static String topic;

2 of 16

How do you declare boolean?

under

public static void main(String[ ] args){

write

boolean correct = false;

3 of 16

How do you output?

System.out.println( enter text here,use "" or a variable);

4 of 16

How do you add a scanner?

Scanner kb= new Scanner(System.in);

5 of 16

How do you read in an input after a scanner?

if it is a string (words) :

String name=kb.nextLine( );

if it is an int (numbers) :

int number=kb.nextInt( );

6 of 16

What are the first 6 lines of code?

package quiz1;

import java.io.*;

import java.util.Scanner;

public class quizOne { 

public static String topic;

public static void main(String[ ] args)[

7 of 16

lines 7-11

boolean correct = false;

System.out.println("Hello, what is your name?");

Scanner kb=new Scanner(System.in);

String name=kb.nextLine( );

System.out.println("Okay, "+name+", pick a quiz, a, b or c?");

8 of 16

lines 12-16

System.out.println("a) Maths");

System.out.println("b) PE");

System.out.println("c) Biology");

String topic=kb.nextLine( );

System.out.println("You chose "+topic+", let's begin!");

9 of 16

lines 17-22

if (topic.equals("a"));

System.out.println("Select a difficulty");

System.out.println("easy, medium or hard");

String level=kb.nextLine( );

if (level.equals("easy"));

System.out.println("Remember to answer with the numeric answer, not the letter!");

10 of 16

lines 23-31

try {

int counter=0;

while (!correct) {

File easy1 = new File ("easy1.txt");

FileInputStream question1a = new FileInputSTream(easy1);

byte [ ] myBytes = new byte[1000];

question1a.read(myBytes);

String myString = new String(myBytes);

System.out.println(myString);

11 of 16

lines 32-37

int answer1a= kb.extInt(  );

if (answer1a==(88)){

System.out.println("Well done, "+name+" You have scored one point!");

correct = true;

counter++

System.out.println("Your score so far is"+counter); }

12 of 16

lines 38-42

else{

System.out.println("Incorrrect!");

correct = false;

System.out.println("Your score so far is "+counter );

}}

13 of 16

lines 43 onwards

correct = false;

while (!correct) {

NOW REPEAT PREVIOUS CODE BUT 

easy1 is now easy2

question1a is now question1b

myBytes is now myBytes1

answer1a isnow answer1b

14 of 16

requirements 1

1)

  • 3 quizzes, tested on two
  • easy medium or hard

2)

  • multiple choice
  • easy - 2 options
  • medium - 3 options
  • hard - 4 options

3)

  • 3 arrays, students' names, ages and year group
  • array for stroing usernames
  • array for password

4) username is created with first 3 letters of student name and followed by age

15 of 16

requirements 2

5)

  • should show quiz score
  •  percentage
  • grade (make up grade boundaries)
  • should be atleast 4 grades

6) two reports

  • A - input username and output quizzes taken and grades achieves
  • B - inputs a quiz topic an difficulty and java should output the average score and top mark and user who achieved the top mark
16 of 16

Comments

No comments have yet been made

Similar Computing resources:

See all Computing resources »See all control resources »