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

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!









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 GOT ERROR FOR MY PROJECT
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 create an icon on my desktop... with this i want to open my web application
i want to protect mysql database table which user can not view to table and can not copy my table till then us
How can I to my database to my application
one error but i dont know how to fix it o_O!!!
i am unable to identify the error in my code
i am unable to identify the error in my code
errore
need to fix errors please help
selectoptions errors in java script
How can i modify my account in roseindia
How can I protect my database password ?
Can I put coursera on my resume?
Can I put online courses on my CV?
Can I learn Hadoop on my own?
Can I learn R on my own?
when I run exiting project that time I got error, I want solution on it?
How can I execute a PHP script using command line?
can i Execute PHP code inside python script?
How can I find my DHCP IP address on my computer?
how can i simplify my java code
How can I connect my database to my application ?
Can someone help me with this?
how can i use toggle button in my application
Hii i want a JMS application can anybody help me
pls review my code - Struts
Want to learn java - How i can learn Java from scratch?
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..
Pls review my code - Struts
pls review my code - Struts
i want to find the byte code of a image file ... for my project..plz if anybody help me for java coding i will grateful..
I want to know the all possible syntax for EL code to print the first element of an array.
could you suggest me that in which area i have to do a project?i want a complete guidence to complete my project.
please how fix this error?
please fix the error
I want Mini Java Project for Student Admission System. actually i want 2 know how 2 start this...please show me my way.....
I want to know how can I create sessionfactory in hibernate 4 (latest version)
I want to learn maven
I want to Transfer only 1/3rd of contents from one folder to other but my code is transferring all contents
How i can send testing mail on my id using java?
how i can add an horizontal scrollbar at my PdfAnnotation ? - JSP-Servlet
How can I start my career in data science?
My Base Class is Changing every time in my code. How I can overcome this?

Ads