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 5 of 5

Thread: Build is having extra unwanted line

  1. #1
    Junior Member
    Join Date
    May 2019
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Build is having extra unwanted line

    /*
    *Function of this build is to ask a student questions about
    *school and have the answers turned into a sentence after answered.
    *
    *I'm getting a line that has all answers combined after the complete
    *sentence is finished.
    *
    */
    package madlibs;
    import java.util.Scanner;

    public class MadLibs {
    public static String major, course, instructor, restaurant, hangout,
    addStatements;
    public static Scanner keyboard = new Scanner(System.in);


    public static void main(String[] args)
    {
    String combineStatements = addStatements();
    System.out.println(combineStatements);
    }

    public static String addStatements()
    {
    System.out.println("What's your major?");
    major = keyboard.next();

    System.out.println("What's your favorite course?");
    course = keyboard.next();

    System.out.println("Whos your favorite instructor?");
    instructor = keyboard.next();

    System.out.println("What's your favorite restaurant on campus?");
    restaurant = keyboard.next();

    System.out.println("What's your favorite hangout place?");
    hangout = keyboard.next();

    addStatements = major + course + instructor + restaurant + hangout;

    System.out.println("My major is " + major + " and I am taking a "
    + "class called " + course + " with the instructor called"
    + " Prof. " + instructor +
    ". After class, I like eating at " + restaurant + " and then"
    + " hanging out in the " + hangout);
    return addStatements;

    }

    }

  2. #2
    Junior Member
    Join Date
    Apr 2019
    Posts
    25
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default Re: Build is having extra unwanted line

    package com.tool.util;
     
    import java.util.Scanner;
     
    public class MadLibrary {
     
        public static String major, course, instructor, restaurant, hangout, addStatements;
        public static Scanner keyboard = new Scanner(System.in);
     
        public static void main(String[] args) {
            addStatements();
        }
     
        public static void addStatements() {
            System.out.println("What's your major?");
            major = keyboard.next();
     
            System.out.println("What's your favorite course?");
            course = keyboard.next();
     
            System.out.println("Whos your favorite instructor?");
            instructor = keyboard.next();
     
            System.out.println("What's your favorite restaurant on campus?");
            restaurant = keyboard.next();
     
            System.out.println("What's your favorite hangout place?");
            hangout = keyboard.next();
     
            addStatements = major + course + instructor + restaurant + hangout;
     
            System.out.println("My major is " + major + " and I am taking a " + "class called " + course + " with the instructor called" + " Prof. " + instructor + ". After class, I like eating at " + restaurant + " and then" + " hanging out in the " + hangout);
     
        }
     
    }

  3. The Following User Says Thank You to veretimothy For This Useful Post:

    blync (May 11th, 2019)

  4. #3
    Junior Member
    Join Date
    May 2019
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Build is having extra unwanted line

    Thank you @veretimothy

  5. #4
    Member John Joe's Avatar
    Join Date
    Jun 2017
    Posts
    277
    My Mood
    Amused
    Thanks
    8
    Thanked 19 Times in 19 Posts

    Default Re: Build is having extra unwanted line

    @veretimothy

    Maybe you can write some comment on your answer next time instead of just giving answer to OP. I think this will be helpful to OP.
    Whatever you are, be a good one

  6. #5
    Junior Member
    Join Date
    Apr 2019
    Posts
    25
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default Re: Build is having extra unwanted line

    remove two line:

    System.out.println(combineStatements);

    and

    addStatements = major + course + instructor + restaurant + hangout;

Similar Threads

  1. Difference between Maven Build and Eclipse Build
    By Beginner2java in forum Java IDEs
    Replies: 2
    Last Post: October 14th, 2013, 10:13 AM
  2. Difference between Maven Build and Eclipse Build
    By Beginner2java in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 14th, 2013, 10:13 AM
  3. Difference between Maven Build and Eclipse Build
    By Beginner2java in forum Java IDEs
    Replies: 1
    Last Post: October 14th, 2013, 10:09 AM
  4. Difference between Maven Build and Eclipse Build
    By Beginner2java in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 14th, 2013, 10:09 AM
  5. Unwanted appendices
    By Kee-Lee-Ann in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 5th, 2012, 05:25 PM