

SpaceTicket.java
import java.util.Random;
import java.util.Scanner;
public class SpaceTicket {
private static final double STUDENT_DISCOUNT = 0.25;
private static final double CHILD_DISCOUNT = 0.35;
public static void main(String[]args)
{
System.out.print("Enter ticket code: ");
Scanner sc = new Scanner(System.in);
String code = sc.nextLine().trim();
// checking whether the ticket code has at least 25
characters
if(code.length() < 25)
{
System.out.println("\n*** Invalid ticket code ***\nTicket code must
have at least 25 characters.\n");
System.exit(0);
}
// assuming price always has 8 digits; 9 because substring excludes
the end index
String price = code.substring(0, 8);
double ticketPrice = Double.parseDouble(price.substring(0, 6) + "."
+ price.substring(6));
// now extracting the category and applying the discount
char category = code.charAt(8);
double cost = 0;
switch(category)
{
case 's':
cost = ticketPrice - (STUDENT_DISCOUNT * ticketPrice);
break;
case 'c':
cost = ticketPrice - (CHILD_DISCOUNT * ticketPrice);
break;
default:
cost = ticketPrice;
break;
}
// extracting the time
String time = code.substring(9, 11) + ":" + code.substring(11,
13);
// extracting the date
String date = code.substring(13, 15) + "/" + code.substring(15, 17)
+ "/" + code.substring(17, 21);
// extracting the seat number
String seatNumber = code.substring(21, 24);
// extracting the ticket description
String ticketDesc = code.substring(24);
// generating the prize number
Random rand = new Random();
int prize = rand.nextInt(999999) + 1;
String prizeNum = String.valueOf(prize);
int padding = 0;
String zeros = "";
if(prizeNum.length() < 6)
padding = 6 - prizeNum.length();
for(int i = 0; i < padding; i++)
{
zeros += "0";
}
prizeNum = zeros + prizeNum;
/* DISPLAYING ALL THE DETAILS */
System.out.println("\nSpace Ticket: " + ticketDesc);
System.out.println("Date: " + date + "\tTime: " + time + "\tSeat: "
+ seatNumber);
System.out.println("Price: $" + String.format("%,.2f", ticketPrice)
+ "\tCategory: " + category + "\tCost: $"
+ String.format("%,.2f", cost));
System.out.println("Prize Number: " + prizeNum + "\n");
}
}
******************************************************************* SCREENSHOT ********************************************************




Project: Using Java API Classes Page 3 of 5 SpaceTicket.java Requirements: The purpose of this program is accept coded...
For this program, you will be working with data from the NASA website which lists Near Earth Objects detected by the JPL Sentry System. You are given a text file listing the designation and impact probability (with Earth, generally within the next 100 years) of 585 Near Earth Objects. Your job will be to sort these objects by their impact probabilities. Input File Format The input file contains 585 records. Each record is on a separate line. Each line contains...
In this lab you will implement tickets-for-seat-management system. The basic idea is that your program reads an event number and seat number request from a user, and determines if the seat is available (and marks it taken if it was), or is unavailable (so asking the user to choose again). As part of that exercise, you’ll be working with a file of “canned” requests to exercise your program. That is, instead of typing the requests in to your program, the...
I need help writing python code with following instructions. You will write a program that reads a data file. The data file contains ticket IDs and ticket prices. Your job is to read these tickets (and prices). find minimum, maximum and average ticket prices and output a report file. The report file should look exactly (or better than) the one attached (output.txt). Input: A31 149.99 B31 49.99 A41 179.99 F31 169.99 A35 179.99 A44 169.99 open "input.txt" file using open()...
Modify When executing on the command line having only this program name, the program will accept keyboard input and display such until the user does control+break to exit the program. The new code should within only this case situation “if (argc == 1){ /* no args; copy standard input */” Replace line #20 “filecopy(stdin, stdout);” with your new code. Open read a text file “7NoInputFileResponse.txt” that contains a message “There were no arguments on the command line to be tested...
GENERAL INSTRUCTIONS All requirements specified on page 64-67 of the course packet “2.5 Programming Assignment Submission Requirements” and “2.6 Flow Chart Symbols” should be followed. Plan the programs on paper before you attempt to write any programs (it will take less time to complete the assignment overall). Electronic version of your programs (the .m files you create) must be uploaded to Canvas. Attach multiple files to one submission. All files must be received by the beginning of...
Help Please on JAVA Project: Validating the input is where I need help. Thank you Requirements description: Assume you work part-time at a sandwich store. As the only employee who knows java programming, you help to write a sandwich ordering application for the store. The following is a brief requirement description with some sample output. 1. Selecting bread When the program starts, it first shows a list/menu of sandwich breads and their prices, then asks a user to select a...
Assignment You will be developing a speeding ticket fee calculator. This program will ask for a ticket file, which is produced by a central police database, and your program will output to a file or to the console depending on the command line arguments. Furthermore, your program will restrict the output to the starting and ending dates given by the user. The ticket fee is calculated using four multipliers, depending on the type of road the ticket was issued: Interstate...
Need help with java programming. Here is what I need to do: Write a Java program that could help test programs that use text files. Your program will copy an input file to standard output, but whenever it sees a “$integer”, will replace that variable by a corresponding value in a 2ndfile, which will be called the “variable value file”. The requirements for the assignment: 1. The input and variable value file are both text files that will be specified in...
Please use Java to write the program The purpose of this lab is to practice using inheritance and polymorphism. We need a set of classes for an Insurance company. Insurance companies offer many different types of policies: car, homeowners, flood, earthquake, health, etc. Insurance policies have a lot of data and behavior in common. But they also have differences. You want to build each insurance policy class so that you can reuse as much code as possible. Avoid duplicating code....
C PROGRAM, A FOPEN FILE NEED TO BE CREATED Objective To review reading from a file. To use records (an instance of a struct) To use Dynamic Memory Allocation To create and use a dynamically allocated array of structs To use enumerated types in a useful manner (more info given on Discussion board!) The Problem Bad economic times has forced the UCF administration to think outside the box for alternative methods of income. Specifically, we now have a UCF lottery,...