# Hi everyone... need help in thisss

• 07-13-2013, 07:51 AM
kai
Hi everyone... need help in thisss
hi everyone

i cannot figure this out as i only started to learn this

plz help meee =:(sweat)::(sweat):

this is my code so far

Code:

```import java.util.*; import java.text.*; public class Interest {       static DecimalFormat fmt=new DecimalFormat("0.00");     static Scanner input=new Scanner(System.in).useDelimiter("\r\n");       public static void main(String[] args) {               int choice,interestEarn,days;         double principle, rate,result;               do         {                         System.out.println("          Interest Calculator          ");         System.out.println("===========================================");         System.out.println("1) Calculate interest payable");         System.out.println("2) Calculate principle required to earn \$x of interest");         System.out.println("3) Calculate time required to earn \$x of interest");         System.out.println("4) Exit program");               System.out.print("\nPlease select your choice <1-4>  :");         choice= input.nextInt();         System.out.println("");         System.out.println("---------------------------------------------------");     switch (choice)     {     case 1:             System.out.print("Enter the principle amount \$ :");             principle=input.nextInt();             System.out.print("Enter interest rate in % :");             rate=input.nextDouble();             System.out.print("Enter the period <time> in days  :");             days=input.nextInt();                       result=(principle)*(rate/100)*(days/365.0);             System.out.println("Interest earn for principle of \$"+fmt.format(principle)+" at the interest rate of "+fmt.format(rate)+ " % is \$ "+fmt.format(result)+"");             System.out.println("*************************************************************"); break;     case 2:         System.out.print("Enter interest  amount to be earned in \$ :");         interestEarn=input.nextInt();         System.out.print("Enter interest rate in % :");         rate=input.nextDouble();         System.out.print("Enter the period <time> in days  :");         days=input.nextInt();                 principle= interestEarn /(rate/100 * days/365);         System.out.println("To earn an interest of \$"+fmt.format(interestEarn)+",over the period of "+(days)+" days, you need a principle of "+fmt.format(principle)+"");         System.out.println("*************************************************************"); break;     case 3:                 System.out.print("Enter interest  amount to be earned in \$ :");         interestEarn=input.nextInt();         System.out.print("Enter interest rate in % :");         rate=input.nextDouble();         System.out.print("Enter the principle amount in \$  :");         principle=input.nextDouble();               days= (int) (interestEarn/(principle*rate/100*1/365.0));         System.out.println("To earn an interest of \$"+fmt.format(interestEarn)+",with principle of \$ "+fmt.format(principle)+",time required is "+days+  " days.");         System.out.println("*************************************************************");         break;           case 4:       System.out.println("        Principle                Rate                Days            Interest                Total");       System.out.println("          <\$>                        <%>                            <\$>                          <\$>");                                                                                                    System.out.println("        ---------          ------          ------                ---------                -------");                                                         System.out.println("Exiting program.....");         System.out.println("***************************");         System.out.println();         System.out.println("Press any key to continue...");         break;               default:                       System.out.println("Invalid Choice!!!, Please enter <1-4> only");     } System.out.println("");                 }    while(choice!=4);         }       }```
• 07-13-2013, 10:52 AM
Toll
Re: Hi everyone... need help in thisss
So... what's your question? What works/doesn't work? What do you get/what do you expect?
• 07-13-2013, 02:08 PM
DarrylBurke
Re: Hi everyone... need help in thisss
Quote:

Originally Posted by kai
Hi everyone... need help in thisss

Please go through the Forum Rules, particularly the third paragraph.

db
• 07-14-2013, 07:44 AM
kai
Re: Hi everyone... need help in thisss
sorrry mod.... =(

anw this is wat i need to get
• 07-14-2013, 08:26 AM
Toll
Re: Hi everyone... need help in thisss
And what do you get right now? To clarify: We're not a code-factory. We won't do your assignment for you. If you get stuck somewhere and don't know how to proceed from there, we can help you figure that bit out, but right now I have no clue where you're stuck.
• 07-14-2013, 08:43 AM
kai
Re: Hi everyone... need help in thisss
Quote:

Originally Posted by Toll
And what do you get right now? To clarify: We're not a code-factory. We won't do your assignment for you. If you get stuck somewhere and don't know how to proceed from there, we can help you figure that bit out, but right now I have no clue where you're stuck.

I am not asking you to "code -factory" or watever.. i just need help on how to get that kind of result...i just need need a little help...like how you said it
i do not know if its array or sumthing else...

if you cant help.. its okay thx for reading...
• 07-14-2013, 09:03 AM
kai
Re: Hi everyone... need help in thisss
sorry for being a little rude...
ok basically
lemme try clarify this...

what i exactly need is.... results i got from my codes i wrote above...
ummm
...
when i run the the program... when i press 4.. it exited the program right?

so after i input all the interest priciple etc.... it shows results right...?

... i want all the all results the to appear when i exit the program( press 4)?

i hope it does make it clear... serious... i too do not know how to explain wat i want hmmm :(sweat):
• 07-14-2013, 09:14 AM
Toll
Re: Hi everyone... need help in thisss
Ah, now we're getting somewhere. I assume the numbers to be shown when you press 4 comes from what you've entered into the program before? If so, you need to store those values somehow before printing them out. It's hard to suggest something specific without knowing what you've used so far though... You could use arrays, but they aren't very flexible. You could use a LinkedList and write a new class to keep track of the values, but I don't know if you've done that before. Did you get any directions for the assignment?
• 07-14-2013, 09:27 AM
kai
Re: Hi everyone... need help in thisss
yes.. i would get all those numbers i circled in red after i press number 4....and exit the program..

yeah im sorry... i guess i was too impatient:=(:

i dont think so... im learning really really really really basics.... so arrays should be enough?

seriously you get wat i meant?:s: i dont even get wat im saying sigh

noo... is just says mininum array is 10 thats all
• 07-14-2013, 09:29 AM
Toll
Re: Hi everyone... need help in thisss
Then it sounds like it wants you to use arrays. Have you worked with them before or know how to use them?
• 07-14-2013, 09:33 AM
kai
Re: Hi everyone... need help in thisss
i am having trouble with it actually... i only know it is like can store multiple values?
• 07-14-2013, 09:41 AM
Toll
Re: Hi everyone... need help in thisss
That's about the gist of it, yes. Arrays are created with a specific size in mind (thus the "not very flexible" part). If you create an array with a length of 10, then you will have 10 slots to store values in. Here's a quick example:

int[] intArray=new int[5];
intArray[0]=1;
System.out.println(intArray[0]);

The first line is the declaration. I say it's an array of ints (the int[] part), and I set its size to 5. The second and third line is using the values of the variable. Note that arrays are indexed between 0 and size-1, so in the above example, I'd use 0, 1, 2, 3 and 4 to get to the five different values.

There is, of course, a lot more to arrays than what I used above, but it should be what you need for this assignment.
• 07-14-2013, 09:58 AM
kai
Re: Hi everyone... need help in thisss
hmmm... it makes more sense now..
i will try it out ...

err thanks a lot

and sorry again for my attitute b4:(handshake):