Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!