Results 1 to 13 of 13
Like Tree1Likes
  • 1 Post By kai

Thread: Hi everyone... need help in thisss

  1. #1
    kai
    kai is offline Member
    Join Date
    Jul 2013
    Posts
    12
    Rep Power
    0

    Unhappy Hi everyone... need help in thisss

    hi everyone


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

    plz help meee =


    this is my code so far

    Java 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);
            }
       
        }
    Attached Thumbnails Attached Thumbnails Hi everyone... need help in thisss-camerazoom-20130713134244065.jpg  
    Last edited by JosAH; 07-13-2013 at 09:01 AM. Reason: added [code] ... [/code] tags

  2. #2
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    393
    Rep Power
    4

    Default 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?

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,455
    Rep Power
    20

    Default Re: Hi everyone... need help in thisss

    Quote Originally Posted by kai View Post
    Hi everyone... need help in thisss
    Please go through the Forum Rules, particularly the third paragraph.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    kai
    kai is offline Member
    Join Date
    Jul 2013
    Posts
    12
    Rep Power
    0

    Default Re: Hi everyone... need help in thisss

    sorrry mod.... =(







    anw this is wat i need to get
    Attached Thumbnails Attached Thumbnails Hi everyone... need help in thisss-1.jpg  

  5. #5
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    393
    Rep Power
    4

    Default 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.

  6. #6
    kai
    kai is offline Member
    Join Date
    Jul 2013
    Posts
    12
    Rep Power
    0

    Default Re: Hi everyone... need help in thisss

    Quote Originally Posted by Toll View Post
    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...

  7. #7
    kai
    kai is offline Member
    Join Date
    Jul 2013
    Posts
    12
    Rep Power
    0

    Default 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

  8. #8
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    393
    Rep Power
    4

    Default 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?

  9. #9
    kai
    kai is offline Member
    Join Date
    Jul 2013
    Posts
    12
    Rep Power
    0

    Default 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? i dont even get wat im saying sigh

    noo... is just says mininum array is 10 thats all

  10. #10
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    393
    Rep Power
    4

    Default 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?

  11. #11
    kai
    kai is offline Member
    Join Date
    Jul 2013
    Posts
    12
    Rep Power
    0

    Default Re: Hi everyone... need help in thisss

    i am having trouble with it actually... i only know it is like can store multiple values?

  12. #12
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    393
    Rep Power
    4

    Default 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.

  13. #13
    kai
    kai is offline Member
    Join Date
    Jul 2013
    Posts
    12
    Rep Power
    0

    Default 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
    simminni likes this.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •