Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Zach
Can someone review my script for an apparent parsing error? -it isn't quite finished yet, but I want to fix error first
3 Answer(s)      3 years and 8 months ago
Posted in : Java Beginners


 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");
            }
        }
    }

Advertisement
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:
Advertisements
 

 

 

DMCA.com