Assignemnt #39

Code


 /// Name: Daniel Nguyen
 /// Period: 6
 /// Program Name: SuperQuiz Program
 /// File Name: SuperQuiz.java
 /// Date Finished: 9/9/2015

import java.util.Scanner ;
public class SuperQuiz
{
	public static void main( String[] args )
	{
        Scanner keyboard = new Scanner(System.in);
        
        int q1, q2, q3, score;
        String yn;
        score = 0;
         System.out.print( "Are you ready for a quiz? " );
         yn = keyboard.next();
       System.out.println( "" );
        System.out.println( "Q1) What is the capital of California?" );
            System.out.println( "1) Melbourne" );
            System.out.println( "2) Sacramento" );
            System.out.println( "3) Juneau" );
        q1 = keyboard.nextInt();
        if (q1 == 2) {
            System.out.println( "That's Correct!!!" );
            score += 1;
        }
        else if (q1 != 2) {
            System.out.println( "That's Incorrect.. The capital of California is Sacramento." );
        }
        System.out.println( "" );
        System.out.println( "Q2) What is 1+3?" );
            System.out.println( "1) 1" );
            System.out.println( "2) 5" );
            System.out.println( "3) 4" );
        q2 = keyboard.nextInt();
        if (q2 == 3) {
            System.out.println( "That's Correct!!!" );
            score += 1;
        }
        else if (q2 != 3) {
            System.out.println( "That's Incorrect... 1 + 3 = 4" );   
        }
        System.out.println( "" );
        System.out.println( "Q3) What is the color of an orange?" );
            System.out.println( "1) Purple" );
            System.out.println( "2) Orange" );
            System.out.println( "3) Gray" );
        q3 = keyboard.nextInt();
        if (q3 == 2) {
            System.out.println( "That's Correct!!!" );
            score += 1;
        }
        else if (q3 != 2) {
            System.out.println( "That's Incorrect.. The color of an orange is... orange." );
        }
        System.out.println( "" );
       if (score == 3) {
            System.out.println( "+----+" );
         System.out.println( "|100%| Great Job!" );  
                  System.out.println( "+----+" );
        }
        if (score == 2) {
        System.out.println( "+---+" );
         System.out.println( "|66%| Eh... You did okay" );
              System.out.println( "+---+" );
        }
        if (score == 1) {
              System.out.println( "+---+" );
         System.out.println( "|33%| That was terrible." );   
                    System.out.println( "+---+" );
        }
        if (score == 0) {
              System.out.println( "+--+" );
         System.out.println( "|0%| You have 0% common sense as well." );
                    System.out.println( "+--+" );
        }
        System.out.println( "" );
    }
}

    

Picture of the output

Assignment 3
BACK HOME NEXT