-
Java Program Help.
I'm on chapter 9(Inheritance and Polymorphism) of this textbook that teaches java. It's supposed to be a basic program but I am so lost with this. I need to see how this program should be written:
Create Personal Acct and BusinessAcct classes that inherit the Account class presented Chapter 8(Classes and Object Oriented Development). A Personal account requires a minimum balance of $100. If the balance falls below this amount then $2.0 is charged(withdrawn) to the account. A business account requires a minimum balance of $500, otherwise the account is charged $10. Create Client Code to test the classes.
I tried using strings and I messed it up, everytime I ran my program it would say I have an issue with how I connected them. could you show me how it could be done using strings correctly? Keep in mind, it might be easy for you but I started doing java only a couple of months ago so I learn a lot with trial and error and comparing to whatever I can spew out lol.
Thanks so much everyone!
-
Re: Java Program Help.
Please post your code and the full text of the error messages you are getting and your questions.
-
Re: Java Program Help.
I'm at home right now and I don't have my program on me(it's on my school files). I'm planning on comparing them tomorrow.
It's asking for this:
"Create Personal Acct and BusinessAcct classes that inherit the Account class presented Chapter 8(Classes and Object Oriented Development). A Personal account requires a minimum balance of $100. If the balance falls below this amount then $2.0 is charged(withdrawn) to the account. A business account requires a minimum balance of $500, otherwise the account is charged $10. Create Client Code to test the classes."
I suspected strings should work but it said something about them not connecting properly for this sequence. I'm not that good but I'm doing these practice problems daily but the way this book is so far, it's practically all basics but obviously i'm still a beginner. A really bad one at that lol.
-
Re: Java Program Help.
Which thread do you want to use for this question? Select one to avoid confusion.
Also posted at http://www.javaprogrammingforums.com...html#post68454
and http://www.java-forums.org/new-java/...lp-please.html
Your last post doesn't give any more information than the first one.
-
Re: Java Program Help.
I guess I'll use this thread? Like I said I don't have the code on me at the moment because it's on my school file, I won't have access to these forums tomorrow which I why I asked if someone knows how to write this and how it would be written. I want to compare them for tomorrow and see what I did wrong. I'm using JDK 5.0, I am not taking a class for this but trying to do self-learning anyways we do have accesible java programs in the labs and my computer has problems using jcreator or eclipse. Some mistakes that I remember it said I got were: Unused private methods, which I don't understad how. Something about how my methods not working. I think there was something about the imports too..
I'm literally going from memory and I could have some things wrong.
-
Re: Java Program Help.
I used strings in the program Exercise 1, which looks like this:
01 import java.util.*;
02 import java.lang.*;
03
04 public class Chapter_9_1 {
05
06 public static void main(String[] args) {
07
08 Scanner input = new Scanner(System.in);
09 String answer;
10 String Group1 = "Science Department:\nMembers: John - 1337H4X\n Jessica - 8192354\n Dick - 1102934\n"
11 + " Bill - L291A72\n Sally - 88NG109";
12 String Group2 = "English Department:\nMembers: Tyler - 81U03MW\n Gregory - 902RE76\n Tim - AA465D3\n"
13 + " Frank - 876EH93\n Krystal - KF00UE1";
14
15 do{
16 System.out.print("Enter a Faculty or an employee number or 'List' to see groups and members or 'quit' to quit: ");
17 answer = input.nextLine();
18 answer.trim();
19 if(answer.equalsIgnoreCase("sciencedepartment") || answer.equalsIgnoreCase("science department")){
20 System.out.println(Group1);
21 }else if(answer.equalsIgnoreCase("englishdepartment") || answer.equalsIgnoreCase("englishdepartment")){
22 System.out.println(Group2);
23 }else if(answer.equalsIgnoreCase("list")){
24 System.out.println(Group1);
25 System.out.println(Group2);
26 }else if(answer.equals("1337H4X")){
27 System.out.println("John, Salary: $35,000, Department: Science, Job Title: Teacher");
28 }else if(answer.equals("8192354")){
29 System.out.println("Jessica, Salary: $35,000, Department: Science, Job Title: Teacher");
30 }else if(answer.equals("1102934")){
31 System.out.println("Dick, Salary: $15,000, Department: Science, Job Title: Part-time Teacher");
32 }else if(answer.equals("L291A72")){
33 System.out.println("Bill, Salary: $50,000, Department: Science, Job Title: Department Head/Teacher");
34 }else if(answer.equals("81U03MW")){
35 System.out.println("Tyler, Salary: $15,000, Department: English, Job Title: Part-time Librarian");
36 }else if(answer.equals("902RE76")){
37 System.out.println("Gregory, Salary: $35,000, Department: English, Job Title: Teacher");
38 }else if(answer.equals("AA465D3")){
39 System.out.println("Tim, Salary: $50,000, Department: English, Job Title: Department Head");
40 }else if(answer.equals("876EH93")){
41 System.out.println("Frank, Salary: $35,000, Department: English, Job Title: Teacher");
42 }else if(answer.equals("KF00UE1")){
43 System.out.println("Krystal, Salary: $35,000, Department: English, Job Title: Teacher");
44 }else if(answer.equals("88NG109")){
45 System.out.println("Sally, Salary: $35,000, Department: Science, Job Tital: Teacher");
46 }
47 System.out.println("");
48 }while( !(answer.equalsIgnoreCase("quit")) );
49
50
51
52 }
53 }
This was the first exercise in Chap 9, I'm doing self learning so I don't really know where I'm going with it and I've only recently started. I suspected that I should use strings like the program above. (I haven't sent myself my corrupted code for the one I'm doing right now because my computer at home has problems running jcreator pro or eclipse, so I do everything in school. I want to see how this is done so I can compare it in the lab(I don't have a java class for this I'm literally trying to learn this for fun) and I can't access forums there so I was trying to get it tonight to compare tomorrow. Now I need help with exercise 2 which I'm guessing needs strings or me to extend classes.
-
Re: Java Program Help.
Please edit your post and remove the numbers from the first column. Also wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting.
If you are getting error messages, please copy and paste the full text here.