Can someone review my script for an apparent parsing error? -it isn't quite finished yet, but I want to fix error first

Ads
 

Can someone review my script for an apparent parsing error? -it isn't quite finished yet, but I want to fix error first

 import java.util.Scanner;

    class historyquiz{
        public static void main(String args[]){
            Scanner ans = new Scanner(System.in);
            System.out.println("1 = Dwight L. Moody; 2 = Ira Sankey; 3 = T. De Witt Talmage; 4 = B. H. Caroll");
            System.out.println("Who was America's best known urban evangelist?");
            if(ans.nextInt() == 1){
                System.out.println("Correct!");
            }else{
                System.out.println("Incorrect");
            System.out.println("1 = Dwight L. Moody; 2 = R. A. Torrey; 3 = General William Booth; 4 = Wilbur Chapman");
            System.out.println("Who founded the Salvation Army?");
            if(ans.nextInt() == 3){
                System.out.println("Correct!");
            }else{
                System.out.println("Incorrect");
            System.out.println("1 = 1884; 2 = 1892; 3 = 1951; 4 = 1877");
            System.out.println("In Which year did Sheldon Jackson introduce 171 reindeer to Siberia?");
            if(ans.nextInt() == 2){
                System.out.println("Correct!");
            }else{
                System.out.println("Incorrect");
            System.out.println("1 = Mount Hermon; 2 = Hawaii; 3 = France; 4 = Portugal");
            System.out.println("Where did Dwight L. Moody sponsor a Christian Confrence in 1886?");
            if(ans.nextInt() == 1){
                System.out.println("Correct!");
            }else{
                System.out.println("Incorrect");
            System.out.println("1 = Ole' Deluder Satan movement; 2 = Student Volunteer movement; 3 = Evangelization movement; 4 = Spread the Word movement");
            System.out.println("Which movement's watchword was, 'evangelize to the world in this generation.'?");
            if(ans.nextInt() == 2){
                System.out.println("Correct!");
            }else{
                System.out.println("Incorrect");
            System.out.println("1 = x; 2 = x; 3 = x; 4 = x");
            System.out.println("");
            if(ans.nextInt() == 1){
                System.out.println("Correct!");
            }else{
                System.out.println("Incorrect");
            System.out.println("1 = x; 2 = x; 3 = x; 4 = x");
            System.out.println("");
            if(ans.nextInt() == 1){
                System.out.println("Correct!");
            }else{
                System.out.println("Incorrect");
            System.out.println("1 = x; 2 = x; 3 = x; 4 = x");
            System.out.println("");
            if(ans.nextInt() == 1){
                System.out.println("Correct!");
            }else{
                System.out.println("Incorrect");
            System.out.println("1 = x; 2 = x; 3 = x; 4 = x");
            System.out.println("");
            if(ans.nextInt() == 1){
                System.out.println("Correct!");
            }else{
                System.out.println("Incorrect");
            System.out.println("1 = x; 2 = x; 3 = x; 4 = x");
            System.out.println("");
            if(ans.nextInt() == 1){
                System.out.println("Correct!");
            }else{
                System.out.println("Incorrect");
            }
        }
    }
View Answers

January 21, 2011 at 10:43 AM

Hi Friend,

We have modified your code.Check it!

import java.util.Scanner;

class historyquiz{
    public static void main(String args[]){ 
        Scanner ans = new Scanner(System.in); 
        System.out.println("1 = Dwight L. Moody; 2 = Ira Sankey; 3 = T. De Witt Talmage; 4 = B. H. Caroll");
        System.out.println("Who was America's best known urban evangelist?");
        if(ans.nextInt() == 1){
            System.out.println("Correct!"); 
            }
        else{
            System.out.println("Incorrect");
        }
            System.out.println("1 = Dwight L. Moody; 2 = R. A. Torrey; 3 = General William Booth; 4 = Wilbur Chapman");
            System.out.println("Who founded the Salvation Army?");
            if(ans.nextInt() == 3){
            System.out.println("Correct!");
            }
            else{ 
            System.out.println("Incorrect");
            }
            System.out.println("1 = 1884; 2 = 1892; 3 = 1951; 4 = 1877");
            System.out.println("In Which year did Sheldon Jackson introduce 171 reindeer to Siberia?");
            if(ans.nextInt() == 2){
            System.out.println("Correct!");
            }
            else{ 
            System.out.println("Incorrect");
            }
            System.out.println("1 = Mount Hermon; 2 = Hawaii; 3 = France; 4 = Portugal");
            System.out.println("Where did Dwight L. Moody sponsor a Christian Confrence in 1886?");
            if(ans.nextInt() == 1){
            System.out.println("Correct!"); 
            }
            else{ 
            System.out.println("Incorrect");
            }
            System.out.println("1 = Ole' Deluder Satan movement; 2 = Student Volunteer movement; 3 = Evangelization movement; 4 = Spread the Word movement"); 
            System.out.println("Which movement's watchword was, 'evangelize to the world in this generation.'?"); 
            if(ans.nextInt() == 2){
            System.out.println("Correct!");
            }
            else{
            System.out.println("Incorrect");
            }
            System.out.println("1 = x; 2 = x; 3 = x; 4 = x");
            System.out.println("");
            if(ans.nextInt() == 1){
            System.out.println("Correct!");
            }
            else{
            System.out.println("Incorrect");
            }
            System.out.println("1 = x; 2 = x; 3 = x; 4 = x");
            System.out.println(""); 
            if(ans.nextInt() == 1){
            System.out.println("Correct!"); 
            }
            else{ 
            System.out.println("Incorrect"); 
            }
            System.out.println("1 = x; 2 = x; 3 = x; 4 = x"); 
            System.out.println("");
            if(ans.nextInt() == 1){ 
            System.out.println("Correct!"); 
            }
            else{
            System.out.println("Incorrect");
            }
            System.out.println("1 = x; 2 = x; 3 = x; 4 = x");
            System.out.println("");
            if(ans.nextInt() == 1){
            System.out.println("Correct!"); 
            }
            else{ 
            System.out.println("Incorrect");
            }
            System.out.println("1 = x; 2 = x; 3 = x; 4 = x");
            System.out.println("");
            if(ans.nextInt() == 1){
            System.out.println("Correct!");
            }
            else{ 
            System.out.println("Incorrect"); 
            }
            }
            }

Thanks


January 21, 2011 at 8:18 PM

Does anyone know how to get it to be in java format instead of stickint to the left side of the page?


January 21, 2011 at 8:20 PM

Thank you so much, I really appreciate your help!

Ads









Related Tutorials/Questions & Answers:
Can someone review my script for an apparent parsing error? -it isn't quite finished yet, but I want to fix error first
please i want someone to answer me pleeeeeeeeeeeeease...
Advertisements
I want to change my user name on your website ,how can i do this
ModuleNotFoundError: No module named 'my-first-helloworld-script'
i want to protect mysql database table which user can not view to table and can not copy my table till then us
i want to protect mysql database table which user can not view to table and can not copy my table till then us
I GOT ERROR FOR MY PROJECT
i want to create an icon on my desktop... with this i want to open my web application
one error but i dont know how to fix it o_O!!!
can i Execute PHP code inside python script?
How can i modify my account in roseindia
Can someone help me with this?
i am unable to identify the error in my code
i am unable to identify the error in my code
selectoptions errors in java script
Want to learn java - How i can learn Java from scratch?
Hii i want a JMS application can anybody help me
How can I find my DHCP IP address on my computer?
need to fix errors please help
how can i use toggle button in my application
errore
when I run exiting project that time I got error, I want solution on it?
I want to know how can I create sessionfactory in hibernate 4 (latest version)
I want to know the all possible syntax for EL code to print the first element of an array.
How i can send testing mail on my id using java?
can i know the error in this code... am unable to run this code
my hibernate showing the following exception so how i can resolve it
How to disable Browser's back button (at the same time i want my own back button to be enabled) :p
How to disable Browser's back button (at the same time i want my own back button to be enabled) :p
plz check my codings are correct or not...There is an error..i cant find it..
My Base Class is Changing every time in my code. How I can overcome this?

Ads