Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java: The purpose of my assignment is to create a program that will book flight tickets. The program is meant to find the starting and

Java:

The purpose of my assignment is to create a program that will book flight tickets. The program is meant to find the starting and ending point for the flight, which class the user wants to travel and the amount of bags they will carry, and it will then print the sum.

I'm running into two issues right now: One, I'm getting errors on my if statements for the variable TravelClass and subsequently the variable bags. And secondly, for my city inputs that have two words, such as New York for example, the program stops and doesn't proceed to the next step. I'm struggling on how to fix that.

This is a partial code that I have:

import java.util.Scanner; public class Main { public static void main(String[] args) { String start; String end; int TravelClass; int bags; double charge; double cost; double sum; Scanner scan = new Scanner(System.in); System.out.println("Enter your starting point: "); start = scan.next(); if (start.equals("Houston")) { System.out.println("Enter your endpoint: "); end = scan.next(); if (end.equals("Austin")) { System.out.println("Enter travel class (1 - First, 2 - Business, or 3 - Economy: "); TravelClass = scan.nextInt(); if TravelClass = 1 { charge = 956; System.out.println("How many bags will you carry: "); bags = scan.nextInt(); if (bags <= 3) { cost = 0; } if (bags >=4) { cost = 200; } sum = charge + cost; System.out.println("Total cost of ticket from Houston to Austin: $" + sum); } } } 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

=+ What skills and competencies will enable someone

Answered: 1 week ago

Question

=+to live and work wherever he or she wants?

Answered: 1 week ago

Question

=+How will this affect the recruiting process?

Answered: 1 week ago