# Help with simple math in java

• September 15th, 2013, 06:15 PM
TheSteinSide
Help with simple math in java
Hey everyone, I am new to this and I'm having trouble with my code. I need to calculate gross pay and cannot get my code to work. any suggestions?

import java.util.Scanner;
public class theaterProject {
public static void main(String[] args) {
String price1;
int tSold1, gross1;
String movie;
double average;
String tSold11;

// Robert Winter
Scanner input = new Scanner(System.in);
System.out.println("Welcome to Rob Winter's Calculator for calculating profit");

//Movie Title
System.out.println("Enter Movie:");
movie = input.nextLine();
System.out.println("The Movie is " + movie );

//Ticket Price
System.out.println("Enter Ticket Price:");
price1 = input.nextLine();
System.out.println("The price is " + price1 );

//Tickets Sold
System.out.println("How Many Tickets Sold:");
tSold11 = input.nextLine();
System.out.println("Sold Tickets= " + tSold11 );
• September 15th, 2013, 06:38 PM
mstabosz
Re: Help with simple math in java
First off, try wrapping your code in the forum's code tags. {code="java"} and {/code} but with square brackets instead of curly ones. It makes it easier to read.

Second, your code seems to stop short of calculating anything. The tsold1, gross1, and average variables are never used. Using nextLine() to take in the title of the movie as a string is good, but I don't understand why the price and number of tickets sold are also taken in as strings.
• September 16th, 2013, 08:09 PM
anthony5347
Re: Help with simple math in java
As the previous poster said, wrap the code to make it easier to read. Also I noticed there were no brackets at the very end of the code; only at the beginning.