Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: How do i display each loop results

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How do i display each loop results

    import java.util.Scanner;
    import java.util.ArrayList;
    public class HorticultureQuiz
    {
    public static void main (String[] args)
    {

    int c =0;
    int incorrect = 0;
    boolean one = true;
    boolean two = false;
    boolean three = true;
    boolean four = true;
    boolean five = false;
    boolean End = true;
    String first, major, last, confidence;
    Scanner keyboard = new Scanner(System.in);






    for (int i = 0;i<3;i++){


    System.out.println("Enter first name...");
    first = keyboard.nextLine();
    System.out.println("Enter last name ...");
    last = keyboard.nextLine();
    System.out.println("Enter college major...");
    major = keyboard.nextLine();
    System.out.println("When it comes to test taking are your high(overly confident),medium (semi-confident), and low ( not confident)?");
    confidence = keyboard.nextLine();
    System.out.println("\n 1. True or False Traditionly Horticulture deals with garden crops such as fruits, nuts, vegetables, culinary herbs,"+
    " and spices , beverage crops, medicinals and ornamental plants.");
    one = keyboard.nextBoolean();
    if (one == true){
    System.out.println("Off to a great start! Correct Answer!");
    c++;
    }else{
    System.out.println("Incorrect!The correct answer is true!");
    incorrect++;
    }
    System.out.println("2. True or False Fruit is defined as a woody plant that is smaller"
    +" than a tree and generally has several separate stems rather than a single trunk.");
    two = keyboard.nextBoolean();
    if (two == false){
    System.out.println("Correct!! Good Job!");


    c++;
    }else{
    System.out.println("Incorrect! The answer is false, a shurb is defined as a woody plant that is smaller than"
    + " a tree and generally has several separate stems rather than a single trunk.");
    incorrect++;
    }
    System.out.println("3. True or False pH is a value that indicates the acidity or alkalinity of a solution on a scale of 0-14, based on the proportion of H+ ions.");
    three = keyboard.nextBoolean();
    if (three == true ){
    System.out.println("Correct!! Great Job!!");
    c++;
    }else{
    System.out.println("Incorrect Try harder! The right answer is True.");
    incorrect++;
    }
    System.out.println("4. True or False a spider plant is defined as Perennial: Indoor plant during winter used in hanging basket, Narrow,"
    + " arching leaves will have tiny plantlets");
    four = keyboard.nextBoolean();
    if (four == true){
    System.out.println("Correct!! Execellent!!");
    c++;
    }else{
    System.out.println("Wrong! The correct answer is true.");
    incorrect++;
    }
    System.out.println("5. True or False Common Boxwood is defined as perennial: Small deciduous tree: Flower oval shape: Four showy white or pink bracts(flower petals)");
    five = keyboard.nextBoolean();
    if (five == false){
    System.out.println("Correct answer!");
    c++;
    }else{
    System.out.println("Wrong! A Common Boxwood is defined as large green shrub opposite, leathey leaves, dark green above yellow green below.");
    incorrect++;
    }




    }


    }
    }



    This is my code so far. I want to get the results after each loop but I do not know how to do that. And also show the number of correct answer from each loop. I am lost when it comes to this.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: How do i display each loop results

    Can you post what the program prints out now and add some comments saying what you what the output to look like.

    Please edit your post and wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. How to display data from list into web browser with JSTL foreach loop ?
    By banana in forum JavaServer Pages: JSP & JSTL
    Replies: 2
    Last Post: November 13th, 2011, 06:50 PM
  2. Stumped by while loop results
    By mwr76 in forum Loops & Control Statements
    Replies: 4
    Last Post: October 3rd, 2011, 09:31 AM
  3. How to display the results + repeat to the number entered by user?
    By TheBattousaixx in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 17th, 2011, 11:56 PM
  4. How to Accumulate results
    By DreamNaut in forum Java Theory & Questions
    Replies: 2
    Last Post: October 29th, 2010, 01:10 AM
  5. How to use for loop for movement of points in a picture display?
    By Dman in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 8th, 2009, 09:19 AM

Tags for this Thread