comp
- Created by: 13martinl
- Created on: 06-11-17 10:30
How do you declare scanners?
import java.io.*;
import java.util.Scanner;
How do you declare the topic class?
underneath
public class quizone{
write:
public static String topic;
How do you declare boolean?
under
public static void main(String[ ] args){
write
boolean correct = false;
How do you output?
System.out.println( enter text here,use "" or a variable);
How do you add a scanner?
Scanner kb= new Scanner(System.in);
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( );
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)[
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?");
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!");
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!");
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);
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); }
lines 38-42
else{
System.out.println("Incorrrect!");
correct = false;
System.out.println("Your score so far is "+counter );
}}
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
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
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
Related discussions on The Student Room
- Graduate Role Application Anxiety »
- Is this a traffic light sensor or a red light canera »
- does anyone know how to "translate" the shorthand examiners use when marking papers? »
- Torn between Computer Science and Aerospace Engineering »
- do unis expect you to program? »
- Has anyone heard of a company called 'Career Change'? »
- How to revise BTEC IT/Comp.? »
- Should I take comp sci or Politics for A level? »
- MORSE vs Computer Science »
- Would I get an offer? »
Comments
No comments have yet been made