Hello, I'm a beginner at this. This is my assignment and I need to program a calculator. Here is what i have so far:
import java.util.Scanner; public class IntCalc { public static void main(String[] args) { Scanner keyboard = new Scanner (System.in); BigDecimal princ = 0; double interest = 0; char added = '\0'; char type = '\0'; int years = 0; boolean clear = false; boolean done = false; menu(princ, interest, added, type); while(!clear) { //checking for valid inputs if((added != 'a' || added != 's' || added != 'q') && (type != 's' || type != 'c')) { System.out.println("There was an error in your input, please try again."); menu(princ, interest, added, type); } else clear = true; } String header = "Period Beginning Amount Interest Earned Ending Amount "; String out = ""; if(type == 's') out = calcSimple(princ, interest, added, years); else out = calcComp(princ, interest, added, years); System.out.println(header); System.out.println(out); } public String calcSimple(BigDecimal princ, double interest, char added, int years) { String o; BigDecimal amnt = princ; BigDecimal intEarned = princ*interest; int num = 0; if(added == 's') num = years*2; else if(added == 'q') num = years*4; for(int x = 0; x < num; x++) { o += IntegertoString(x+1) + " " + IntegertoString(amnt) + " " + intEarned + " " + amnt+intEarned + "\n"; amnt += intEarned; } return o; } public String calcComp(BigDecimal princ, double interest, char added, int years) { String o; Decimal amnt = princ; BigDecimal intEarned = princ*interest; int num = 0; if(added == 's') num = years*2; else if(added == 'q') num = years*4; for(int x = 0; x < num; x++) { o += IntegertoString(x+1) + " " + IntegertoString(amnt) + " " + princ*interest + " " + amnt+intEarned + "\n"; amnt += intEarned; intEarned = princ*interest; } return o; } public void menu(BigDecimal princ, double interest, char added, char type, int years) { System.out.println ("This program will calculate simple and compound interest."); System.out.println (" "); System.out.println ("What is the principle amount?"); princ=input.next(); System.out.println ("What is the interest rate?"); interest=input.next(); System.out.println ("Will the interst be added anualy, semi-anualy or quartely? (a, s, q)"); added=input.next(); System.out.println("Is the interst simple or compound? (s, c)"); type=input.next(); System.out.println("How many years would you like to calculate the interest for?"); years=input.next(); } }
This is the Error Message I'm getting when I try to compile:
----jGRASP exec: javac -g IntCalc.java IntCalc.java:32: cannot find symbol symbol : class BigDecimal location: class IntCalc public String calcSimple(BigDecimal princ, double interest, char added, int years) ^ IntCalc.java:47: cannot find symbol symbol : class BigDecimal location: class IntCalc public String calcComp(BigDecimal princ, double interest, char added, int years) ^ IntCalc.java:63: cannot find symbol symbol : class BigDecimal location: class IntCalc public void menu(BigDecimal princ, double interest, char added, char type, int years) ^ IntCalc.java:6: cannot find symbol symbol : class BigDecimal location: class IntCalc BigDecimal princ = 0; ^ IntCalc.java:35: cannot find symbol symbol : class BigDecimal location: class IntCalc BigDecimal amnt = princ; ^ IntCalc.java:36: cannot find symbol symbol : class BigDecimal location: class IntCalc BigDecimal intEarned = princ*interest; ^ IntCalc.java:42: cannot find symbol symbol : method IntegertoString(int) location: class IntCalc o += IntegertoString(x+1) + " " + IntegertoString(amnt) + " " + intEarned + " " + amnt+intEarned + "\n"; ^ IntCalc.java:50: cannot find symbol symbol : class Decimal location: class IntCalc Decimal amnt = princ; ^ IntCalc.java:51: cannot find symbol symbol : class BigDecimal location: class IntCalc BigDecimal intEarned = princ*interest; ^ IntCalc.java:57: cannot find symbol symbol : method IntegertoString(int) location: class IntCalc o += IntegertoString(x+1) + " " + IntegertoString(amnt) + " " + princ*interest + " " + amnt+intEarned + "\n"; ^ IntCalc.java:68: cannot find symbol symbol : variable input location: class IntCalc princ=input.next(); ^ IntCalc.java:70: cannot find symbol symbol : variable input location: class IntCalc interest=input.next(); ^ IntCalc.java:72: cannot find symbol symbol : variable input location: class IntCalc added=input.next(); ^ IntCalc.java:74: cannot find symbol symbol : variable input location: class IntCalc type=input.next(); ^ IntCalc.java:76: cannot find symbol symbol : variable input location: class IntCalc years=input.next(); ^ 15 errors ----jGRASP wedge: exit code for process is 1. ----jGRASP: operation complete.
PLEASE HELP ME. Thank you