JGrasp - Writing A Program For Ticket Sales

Sep 13, 2014

The manager of a football stadium wants you to write a program that calculates the total ticket sales after each game. There are four types of tickets: box, sideline, premium, and general admission. After each game, the data is stored in a file in the following format:

ticketPrice numberOfTicketsSold

Sample data might look like:

250 5750

100 28000

50 35750

25 18750

The first line indicates that the box ticket price is $250 and that 5750 tickets were sold at that price.

Your program should input in this data (using Scanner or an input dialog box), then output that data to a message dialog box along with total ticket sales information. Output the total number of tickets sold and the total sale amount. Make your output user-friendly and "pretty". Format your output with two decimal places. Use JOptionPane and the formatting techniques learned in chapter 3 for your output. Example output might be:

5750 Box Tickets sold at $250.00
28000 Sideline Tickets sold at $100.00
35750 Premium Tickets sold at $50.00
18750 General Admission tickets sold at $25.00

View Replies


ADVERTISEMENT

JGrasp - Errors In Writing A Program For Checking And Savings

Sep 19, 2014

Here is the objective of the assignment:

Quote : A bank in your town updates its customers' account at the end of each month. The bank offers two types of accounts: savings and checking. Every customer must maintain a minimum balance. If a customer's balance falls below the minimum, there is a service charge of $10 for savings accounts and $25 for checking accounts. If the balance at the end of the month is at least the minimum balance, the account receives interest as follows:

- Savings accounts receive 4% interest.

- Checking accounts with balances of up to $5000 more than the minimum balance receive 3% interest; otherwise, the interest is 5%.

Write a program that reads a customer's account number (integer), account type (character: s for savings or c for checking), minimum balance that the account should maintain, and the current balance. The program should then output the account number, account type, current balance, and an appropriate message.

Your program should only allow 'c', 'C', 's', or 'S' as valid input, any other character for the account type should result in an error message. Format your monetary output to two decimal places, and use constants for all the above constant values.

Sample output:
Please enter your account number (int), account type (char), minimum balance, and current balance:
46728 S 1000 2700
Account Number: 46728
Account Type: S
You have earned 0.04 interest on your account.
Current Balance: $2808.00

[Code] .....

Invalid account type!

View Replies View Related

Eclipse Java Programming Sales Commissions Array Sales In Ranges

Oct 9, 2014

i have to ask user gross sales until -1 sentinial and to get the commission to put in groups its 9% times the sales add $200
the groups are formatted
a) $200-299
/> $300-399
....
i) $1000 and over

import java.util.Scanner;
public class Commissions {
/**
* @param args

[Code]....

View Replies View Related

Read File Of Sales Records And Produce Sales Report

Jun 29, 2014

Design a program that will read a file of sales records and produce a sales report. Each record in the file contains a customer's ID, name, a sales amount, and a validated GST code. The GST code is to be applied to the sales amount to determine the sales tax due for that sale, as shown below.

GST CodeGST Rate
0
1
20%
5%
10%

The report is to print a heading "SALES REPORT", and detail lines listing the customer's ID, name, sales amount, sales tax, and total amount due including sales tax.

Is assignment
sofar:pseudo code
SalesReport
Read customer file
Get TaxCode
Get GSTAmount SalesTax
Calculate SalesTax

[Code] ....

View Replies View Related

Enter In Sales Amount And Then Get It To Display Asterisk Per 100 In Sales

Apr 3, 2014

{
public static void main (String []args)
{
Scanner numberin = new Scanner (System.in);
double store [];

[Code]....

How would I get my program to display a * for every 100 dollars in sales that the user enters in so: for example the user enters in store 1: $ 400 in sales for the store I want it to display store 1:****

The first part of my code allows the user to enter in whatever values the stores have in sales. The Second half of the code starts at line 19 is my best guess on what I need to do I just am not sure how to get it to display what I need it to.

View Replies View Related

Speed Ticket Program

Jan 5, 2015

public class TextLab03st
{
public static void main(String args[])
{
System.out.println("Text Lab 03");
System.out.println();
System.out.print("What is the posted speed limit? --> ");
int speedLimit = Expo.enterString();
System.out.println("");
System.out.print("How fast was the car travelling in mph? --> ");
int trueSpeed = Expo.enterString();
int ticketPrice;

[code]...

I tried everything and there's supposedly one error saying it reached the end of the file while parsing. I'm trying to make a speeding ticket program for my class.

View Replies View Related

Getting Program To Repeat Itself In JGRASP Without Having To Click Run

Oct 10, 2014

Basically, I have want to keep typing numbers and pressing enter and the same program keeps repeating itself. This is the code I need to repeat,

import java.util.Scanner;
class Averagecalc2 {
public static void main(String args []) {
Scanner input = new Scanner(System.in);
double num,

[Code] .....

View Replies View Related

Software Sales Program

Nov 7, 2014

my project is to design a class that stores the number of units sold and has a method that returns the total cost of the purchase..the given info is unit are $99. discounts are 20% for 10-19 units; 30% for 20-49 units; 40% for 50-99 units; and 50% for 100 or more units purchased... When i run the code and put in the units sold it returns: 0 units sold, $0.00 cost, 0% discount. How do I get the output to actually do the equation and give proper information. We were given a demo file from the instructor and had to create a class that works with it first set of code is the demo file:

package chapter4;
import java.text.DecimalFormat;
import java.util.Scanner;
/**
* SoftwareSalesDemo Program
*/
public class SoftwareSalesDemo {
public static void main(String[] args) {
int units; // To hold units sold

[code]....

View Replies View Related

How To Write A Program Using Quadratic Formula In JGrasp

Mar 4, 2015

Write a program named QuadraticTable.java that takes three double arguments and two int arguments (in that order) from the command line. The three doubles will represent a, b, and c from the quadratic formula.

If the discriminant is non-negative, find and print the solutions to the quadratic equation. (The plus/minus sign in the quadratic formula indicates that you would separately perform both operations). Otherwise print "no real solutions".

Then using the last two int arguments as x_min and x_max, print a table of x and ax

2 + bx + c

values using the a, b, and c read in as command line arguments.

Sample output: (command line arguments were 1 0 2 -3 3)

1x^2 + 0x + 2 has no real solutions.

X 1x^2 + 0x + 2

-3 11

-2 6

-1 2

0 2

1 3

2 6

3 11

View Replies View Related

Program For Airline Ticket Booking - Fixed Origin City And Five Destination Cities

Oct 26, 2014

I am doing a pretty basic program with a fixed origin city and five destination cities. I am having trouble with entering passenger details. This is what I tried, but then I cannot retain all passenger details to print later on in the final ticket.

System.out.println("Enter flight details of child passengers (below 12 years)");
System.out.println("Enter Name");
for(a = 1; a <= cp; ++a)
{
//cp is number of child passengers, a is loop variable
String name = br.readLine();
System.out.println("1. " + name);
}

View Replies View Related

Write A Sales Tax Program With JOptionpane / Illegal Start Of Expression

Oct 19, 2014

I'm trying to write a sales tax program with JOptionpane but I received this message: illegal start of expression

import javax.swing.JOptionPane;
public class SalesTax {
public static void main(String[] args) {
String amount;
double stateSalesTax;
double countySalesTax;
double totalSalesTax;
double totalSaleAmount;
double amt;
JOptionPane.showInput.Dialog("Enter the amount of purchase");

[code]....

View Replies View Related

Writing A Calculation For A Program?

Sep 8, 2014

I am writing a program in Java where a user adds 1 stamp on a letter for every five sheets of paper in it (or fraction thereof)For example, I if I have 11 sheets of paper, I add 3 stamps. If the total number of stamps is more than 3, they don't send it.

I need to ask the user how many sheets of paper they have, and then calculate the appropriate number of stamps based on the formula above. I just don't know how to write the math formula to calculate this, i'm stuck. So far I have:

package test;
import java.util.Scanner;
public class LetterMailing {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
int numSheets;

[Code] .....

What should I do next?

View Replies View Related

Writing A Java Program To PRINT?

Oct 19, 2014

how to print from bluej onto actual paper? how to do the formatting and configuration etc.

View Replies View Related

Writing A Program To Take Input From User?

Oct 23, 2014

Writing a program to take input from user. This input must be done with numbers only. If the input is a string I would like the program to loop and ask for input again.

double depositCheckingAmount;
do
{
System.out.println("Please insert amount to deposit into checking.");

[Code]....

As you can see my attempt is to use the ! expresssion incase the input does not equal a double. Is there another method I should be using?

View Replies View Related

Writing A Program For System Of Linear Equations

Sep 22, 2013

So i was assigned to write a program that would print the answer to the system of two linear equation. the form of ax+by=c and dx+ey=f..I wrote this program, but it is incorrect since I tried it out on my terminal and I keep getting incorrect values.

import java.util.Scanner;
public class Quest4 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);

[code]....

View Replies View Related

Writing A Program To Dynamically Update XML File To Add

Feb 8, 2014

I'm writing a program to dynamically update an xml file to add, delete, and edit entries in the file. I've run into an issue with the add method because when I write into the file, a random letter is added before the line. EX:

I want to add "<item> ..." to the end of the list of entries, but when it is added, this is what is added "Z <item> ..."The spacing for the <item> is correct, however, I don't see where or why the Z is added.

public static void insertItem(Item i)
{
try {
String insert = " <item>";
String text = "";
Scanner in = new Scanner(file);

[code]....

View Replies View Related

Writing A Program To Search Bluetooth Devices

May 2, 2014

Im trying to write a java program to search nearby bluetooth devices.. Im using Bluecove-glp-2.1.0 and bluecove 2.1.0..Im working on Ubuntu 13.04 LTS.I typend a code to get the local Device name..

public class BluetoothSearch {
public static void main(String[] args) {
LocalDevice ld= null ;
String name = ld.getBluetoothAddress();
System.out.print(name);
}
}

this is my code.. It returns me null. doesn't return me the local Device.

View Replies View Related

Writing A Program That Determines If Number Is Palindrome Or Not

Apr 3, 2015

I'm in the process of writing a program that determines if a number is a Palindrome or not. I'm not allowed to use strings and am required to use the getSize method shown below. I believe my issue that I'm having is that the "num" is not being called in the getSize method, and therefore not running the while loop, or at least that is what I believe is the issue.

import javax.swing.*;
public class getSize{
public static void main( String[] args )
{
int num;
num = Integer.parseInt (JOptionPane.showInputDialog ( "Please input a number" ));

[code]....

View Replies View Related

Factorial - Writing Iterative Program Recursively

Apr 30, 2015

It was quite recently that Data Structures was introduced to me, so I started out writing some iterative programs recursively.I found some strange output which shouldn't have come out but if you take a look at these three codes

long factorial(long n)
{
if(n == 1)
{
return 1;
}
else
{
result = n*factorial(n-1);

[Code] ....

These are three versions of the code, achieving the same objective of obtaining a given number and returning the factorial, but in spite of the changes made to the code, they produce the same result. I needed a reason as to why it is so? I tried to dry run all the codes but at some point or the other I got confused, and had to start all over again and couldn't come up with a proper result.

View Replies View Related

Writing A Program To Test Person Class

Nov 4, 2014

User-defined classes. The concept of getters and setters goes right over my head. Right now we're to write a program to test the Person class below. We have to create 2 instances of the class to test each constructor, and test each method.

class Person {
// Data Members
private String name; // The name of this person
private int age; // The age of this person
private char gender; // The gender of this person
// Default constructor
public Person() {
this("Not Given", 0, 'U');

[code]....

then my output will print out the name. But the assignment doesn't tell us to modify the Person class at all, just to create a tester one.

View Replies View Related

Writing A Program That Converts TXT File To HTML

Nov 26, 2014

I need to convert a .txt file to html text, where the first line is changed to have < h1 > < /h1 > around it and the rest is wrapped in < p > < /p > so for example I read a .txt file that says:

chapter 1

this is a sentence

it would output:

<h1>chapter 1</h1>

<p>this is a sentence</p>

here is what I have so far and I cannot get anything to output.

FileInputStream filestream;
BufferedReader reader;
FileOutputStream output;
String firstline;
String body = "<p>";
String line;

[Code] ......

View Replies View Related

Writing Binary Search Program And Keep Getting Errors

Feb 24, 2014

Java Code:

public class Search
{
public static final int NOT_FOUND = -1;
public static int binarySearch( int [ ] a, int x )
{
int low = 0;
int high = a.length - 1;
int mid;
while ( low <= high )

[Code] ....

I keep getting illegal start of expression at ={-3,10,5,24,45.3,10.5}

It says I have 12 errors and I have tried so many things to fix it and I just don't know what to change to make it work.

View Replies View Related

Writing A Program That Searches Array Using Binary Search

Jul 10, 2014

I'm (failing at) writing a program that searches an array using binary search, but I can't get it to work.

My code so far is this:

Java Code:

package sorting;

import java.lang.*;
import java.util.*;
public class sorteh {
public static void main(String [] args){
int[] array=new int [20]; //creates new array
for (int x=0;x<array.length;x++){ //populates array
array[x]=x*3+1;

[code]...

I copied what a website did for the sorting part, but if I have low=0 and high=19, wouldn't mid not be an int?

View Replies View Related

Writing A Program To Make A Tic Tac Toe Game Utilizing Inheritance

May 7, 2014

I am new to programming and we are writing a program to make a tic tac toe game utilizing inheritance, client-supplier, arrays, and EventButton. I am still trying to wrap my head around events and inheritance. We are instructed to write 4 classes (a TicTacToeModel, a TicTacToeView, a TicTacToe Controller, and a TicTacToeButton). I got the TicTacToeModel down, but am having trouble with the other classes.

Instructions for View: Write a class that implements the UML class diagram below. The only purpose of this class is to draw a picture of the specified TicTacToeModel. For purposes of this assignment, we understand a ‘theme’ to include such things as the background color of the tic‐tac‐toe board, the shape and color of the X indicator and the shape and color of the O indicator. While you are free to select your own personalized ‘theme’ your TicTacToeComponent must always be proportionally ‘correct’ regardless of the client‐determined width and height of the Component.

Instructions for the Controller: Write a controller that controls the game. There is one human player (the X player) and the computer player (the O player). The name of the class must be TicTacToeController. In a sense, the controller is the game since the controller will

1) create a TicTacToeModel
2) create a TicTacToeView and
3) create a TicTacToeButton (you must write this class following the design pattern covered in class lectures), a label, and text field such that when the button is pushed, the player moves into the cell selected by the text field. After every player move, the computer moves into a randomly selected empty cell. When the game is over, a text message must be displayed somewhere on the screen the gives the status of the game. While you are free to change the appearance of the controller, the basic elements must be provided

These are our instructions for the TicTacToeButton: create a TicTacToeButton (you must write this class following the design pattern covered in class lectures), a label, and text field such that when the button is pushed, the player moves into the cell selected by the text field. After every player move, the computer moves into a randomly selected empty cell. When the game is over, a text message must be displayed somewhere on the screen the gives the status of the game.And this is the code I have thus far for the button:

import java.awt.event.*;
import java.awt.*;
public class TicTacToeButton extends EventButton{
public TicTacToeButton(int x, int y, int w, int h) {
super("Move");
setBounds(x, y, w, h);

[code]....

View Replies View Related

Writing A Pizza Program - Average Cost Of Order

Oct 9, 2014

I'm trying to write a program that will output the total number of large,medium,and small pizza along with the average cost of an order. I'm stuck on this error , "Else without if" on line 48 else ...medium.

import java.util.Scanner;
public class PizzaOrder
{
public static void main(String[] args)
{
Scanner input = new Scanner (System.in);
double cost,total, average;
String name,response,size,type;
int count,l,m,s;

[code]....

View Replies View Related

Writing A Program Using Switch Statement - Allow Users To Choose Item Of A Menu

Oct 5, 2014

Write a program using switch statement to allow users to choose an item of a menu. For example, the menu looks like the following.

File menu
1. Open
2. Close
3. Save
4. Exit
Enter your choice:

If you type 1, then your program should print out "Open is selected" (double quotes not included).

Notice:
(1) Using Scanner to get user choice;
(2) If the number user input is not in {1,2,3,4}, your program should let user know that.

Here's what I have:

public static void main (String[] args) {
int user = 1
switch (1) {
case value: 1
System.out.println ("Open is selected");

[Code] .....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved