Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7635037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:20:22+00:00 2026-05-31T07:20:22+00:00

I was tasked with creating a small application for college, and have created a

  • 0

I was tasked with creating a small application for college, and have created a simple booking system.
I’m having an issue in that when the program runs, for no reason I can fathom it’s executing the print part of a method but then jumping to the next method without executing the in.next() part of the original method.

I’ve included here in order the abstract class, the class where the issue is occurring, the menu, and the ‘Creation’ class.

I’ve been informed before here my coding (at least naming conventions) are not the best so I apologize for this in advance.

When I altered the class so that wasn’t an extension of raw_Booking it seemed to not have this issue but not sure if that’s relevant.

import java.util.Scanner;

abstract class raw_Booking {


private static String fname;
private static String lname;
private static int HouseNo;
private static String Street;
private static String Postcode;


Scanner in = new Scanner(System.in);


raw_Booking(){
    
    
}

abstract public String Setfname();
abstract public String Setlname();
abstract public int SetHouseNo();
abstract public String SetStreet();
abstract public String SetPostcode();
abstract public String Verification();



}

The problem class (method is SetPostcode):

import java.util.Scanner;
import java.io.*;

class Hotel_Booking extends raw_Booking{



Scanner in = new Scanner(System.in);

private String TheVerification;
private int guests;
private String Roomtype;
private double numbRooms;
private double costStay;
private double nights;
private static String fname;
private static String lname;
private static int HouseNo;
private static String Street;
private static String Postcode;

Hotel_Booking() {
  
    fname = Setfname();  
    lname = Setlname();
    HouseNo = SetHouseNo();
    Street = SetStreet();
    Postcode = SetPostcode();
    TheVerification = Verification();
    Roomtype = setRoomtype();
    guests = guests();
    numbRooms = numbRooms();
    nights = nights();
    costStay = costStay();
    Write_File();
}


public String Setfname(){
    System.out.println();
    System.out.print("Bookers first name please:   ");
    fname = in.next();
    return fname;
}

public String Setlname(){
    
    System.out.println();
    System.out.print("Bookers surname please:   ");
    lname = in.next();
    return lname;
}

public int SetHouseNo(){
   Scanner sc = new Scanner(System.in);
   System.out.println();
   System.out.print("Please enter your house number:   ");
   while (!sc.hasNextInt()) {
       System.out.println();
       System.out.print("You need to enter a number - please re-enter:   ");
       sc.next();
   }
return sc.nextInt();
}


public String SetStreet(){
    System.out.println();
    System.out.print("Please enter your street:   ");
    Street =in.next();
    return Street;
}

public String SetPostcode(){
    
    System.out.println();
    System.out.print("Please enter your postcode:   ");
    Postcode = in.next();
    return Postcode;
}

    
public String Verification(){
    
    System.out.println();
    System.out.print("Please provide your car reg as verification:   ");
    TheVerification = in.next();
    return TheVerification;
    
}
    
public String setRoomtype(){  
    
    System.out.println();
    System.out.print("Would you like a Premiun or Regular room(s)?   ");
    Roomtype = in.next();
    return Roomtype;
}

public int guests(){
    
    System.out.println();
    System.out.print("How many guests will be staying?   ");
    guests = in.nextInt();
    return guests;
 
}
//For every 3 guests their must be 1 room at £50 per night.
//Premiun rooms = price doubled
    
public double numbRooms(){
      
   for(int i=0;i < guests;i++){
       numbRooms = numbRooms+1;
       i = i + 2;
    }
   System.out.println();
   System.out.println("You will require " + numbRooms + " number of rooms");
   return numbRooms;
}

public double nights(){
    
    System.out.println();
    System.out.print("How many nights are you staying?   ");
    nights = in.nextDouble();
    return nights;
}

public double costStay(){

    if(Roomtype.equals("Regular")){
        costStay = (nights * numbRooms)*50;
    }
    else{
        costStay = (nights * numbRooms)*100;
    }
    System.out.println();
    System.out.println("The total cost of your stay will be: " + costStay);
    return costStay;
}

public void Write_File(){
    System.out.println();
    System.out.println("Your details will now be written to file.");
    System.out.println();
    try{
        PrintWriter wr = new PrintWriter(new    FileOutputStream("Hotel_Booking.txt",true));
        wr.println("Name: " + fname+ " " + lname);
        wr.println("Address line one: " + HouseNo + " " + Street);
        wr.println("Postcode: " + Postcode);
        wr.println("Roomtype: " + Roomtype);
        wr.println("Number of rooms: " + numbRooms);
        wr.println("Nights staying: " + nights);
        wr.println("Total cost of stay: " + costStay);
        wr.close();
       }
       
    catch (IOException e){
        System.out.println("Error -- " + e.toString());
        }
    
}
public static String Getfname(){
    return fname;
}

 }

Contains Interface/Menu.

public class Interface{



 public static void Menu(){
    
    System.out.println("Welcome to the booking system select an option");
    System.out.println("1 - Create a new hotel booking");
    System.out.println("2 - Create a new airline booking");
    System.out.println("3 - Create a car hire booking");
    System.out.println("4 - Create a amusement park ticket booking");
    System.out.println("5 - Create a concert ticket booking");
    System.out.println();
    
    
    
    
}

}

Main point of execution:

import java.util.ArrayList;
import java.util.Scanner;

public class Booking_Creation{

static Scanner in = new Scanner(System.in);    

static ArrayList<Hotel_Booking> hotelbookings = new ArrayList<Hotel_Booking>();
static ArrayList<Flight_Booking> flightbookings = new ArrayList<Flight_Booking>();
static ArrayList<Car_Hire> carhirebookings = new ArrayList<Car_Hire>();
static ArrayList<Amusement_Park_Ticket> parkticket = new ArrayList<Amusement_Park_Ticket>();
static ArrayList<Concert_Ticket> concertticket = new ArrayList<Concert_Ticket>();



static int selection;
public static void main(String[] arguments){
    
    Interface.Menu();
    
    selection = in.nextInt();
    
    // COULD ASK THE QUESTIONS HERE????
    /// BUT THE INPUT BIT IS INSIDE THE OTHER CLASS
        
    
    
    switch(selection){
            case 1:
            Hotel_Booking hb = new Hotel_Booking();
            hotelbookings.add(hb);
            break;
            case 2:
            Flight_Booking fb = new Flight_Booking();
            flightbookings.add(fb);
            break;
            case 3:
            Car_Hire ch = new Car_Hire();
            carhirebookings.add(ch);
            break;
            case 4:
            Amusement_Park_Ticket pt = new Amusement_Park_Ticket();
            parkticket.add(pt);
            break;
            case 5:
            Concert_Ticket ct = new Concert_Ticket();
            concertticket.add(ct);
            break;
        }
            

}
}

Example output:

Welcome to the booking system select an option
1 - Create a new hotel booking
2 - Create a new airline booking
3 - Create a car hire booking
4 - Create a amusement park ticket booking
5 - Create a concert ticket booking

1

Bookers first name please:   Herton

Bookers surname please:   Ferford

Please enter your house number:   4

Please enter your street:   Park Lane

Please enter your postcode:   
Please provide your car reg as verification:  KS23
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:20:23+00:00Added an answer on May 31, 2026 at 7:20 am

    After a quick glance to your sample execution, I think that the street name is parsed as two tokens, so the street name is set as “Tulloch” and when prompted for the postcode (as a string), “Park” is read.
    It might be useful to set a pattern on the Scanner.next() method to force a full line as a single token ?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been tasked with creating a program that will generate an amortization schedule.
Recently I have been tasked with creating an application for a business that basically
I have been tasked with creating a program what will create take files in
I have been tasked with creating an application for a company to store current
Hello I have been tasked with creating a fairly complex web application in php,
I am new to WIX and have been tasked with creating an installer that
I've been tasked with creating an application that allows users the ability to enter
I'm tasked with creating a program that turns something like ((X+3)*(X+4)) into a binary
I'm new to visual basic and have been tasked with creating an app that
I have been tasked with creating a service that will be consumed by jQuery

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.