1 Replies - 50 Views - Last Post: 07 February 2012 - 05:31 PM Rate Topic: -----

Topic Sponsor:

#1 Candise Wise  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 07-February 12

Error Messages on Parse part.

Posted 07 February 2012 - 04:35 PM

Sorry I ment to post it like this.
import java.io.*;
 
public class Balance
 {
 public static void main(String[] args) throws IOException
 {
 //Declare and Construct Variables
 String balance, checks, startingBalance, deposits, fees, count;
 float endingBalance;
 BufferedReader dataIn= new BufferedReader(new InputStreamReader(System.in));
 
//Print prompts and get input
 System.out.println("\tTBalancing Your Checkbook");
 System.out.println();
 System.out.println("\t\tWhat is the balance from your last statement?");
 balance = dataIn.readLine();
 startingBalance = String .parseInt(balance);
 
System.out.println("\t\tWhat is the total amount of all deposits?");
 deposits = dataIn.readLine();
 checks = String.parseInt(deposits);
 
System.out.println("\t\tWhat is the total amount of all checks?");
 checks = dataIn.readLine();
 count = string.parseInt(checks);
 
System.out.println("\t\tWhat is the total amount of all transacation fees?");
 fees = dataIn.readLine();
 deposits = string.parseInt(fees);
 
//Calculations
 endingBalance = startingBalance+deposits-(checks+fees);
 




// Output 
System.out.println("\t\tYour new balance is " + endingBalance);
 
}
 }
 


Is This A Good Question/Topic? 0
  • +

Replies To: Error Messages on Parse part.

#2 ianian112  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 106
  • View blog
  • Posts: 359
  • Joined: 28-November 09

Re: Error Messages on Parse part.

Posted 07 February 2012 - 05:31 PM

first of all string should be String, second of all you use use Integer.parseInt(String t) or Integer.valueOf(String t), to go from String to Integer.

This post has been edited by ianian112: 07 February 2012 - 05:31 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1