How could i convert this code to pascal and c?

This is about savings quickie program...

Page 1 of 1

1 Replies - 1004 Views - Last Post: 15 March 2008 - 07:24 PM Rate Topic: -----

#1 zkim  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 11-March 08

How could i convert this code to pascal and c?

Post icon  Posted 12 March 2008 - 11:24 PM

class saving{


        public static void main(String arg[]) throws IOException {
        BufferedReader stdin =
        new BufferedReader ( new InputStreamReader (System.in));
        DecimalFormat twoDigitsPastPoint = new DecimalFormat("0.00");
        // Variables Declation
        String get_P_Balance, get_P_Interest, get_No_Years;
        String get_P_Balance2, get_P_Interest2, get_No_Years2;
        String answer;
        double n_Number_Years=0;
        double n_P_Balance=0.00, n_P_Interest=0.00;
        double n_Final_Solve=0.00;
        int a=0;
        char reply;
        System.out.print("\n\t =========================================");
        System.out.print("\n\t ==Savings Quickie Version 1.0===");
        System.out.print("\n\t =========================================");
        System.out.print("\n\n");
        System.out.print("ENTER PRESENT SAVINGS BALANCE :=> $ ");
        get_P_Balance= stdin.readLine();
        n_P_Balance = Double.parseDouble(get_P_Balance);
        System.out.print("ENTER INTEREST RATE PERCENT :=> ");
        get_P_Interest= stdin.readLine();
        n_P_Interest = Double.parseDouble(get_P_Interest);
        System.out.print("ENTER NUMBER OF YEARS :=> ");
        get_No_Years= stdin.readLine();
        n_Number_Years = Double.parseDouble(get_No_Years);
        System.out.print("\n");
        System.out.print(" === COMPUTED RESULTS === ");
        System.out.print("\n\n");


            for (a=1; a<= n_Number_Years; a++) {
            n_Final_Solve =n_Final_Solve + n_P_Interest * (n_Final_Solve + n_P_Balance) /100;
            System.out.println("Year No. "+ a + " => $ " + twoDigitsPastPoint.format(n_Final_Solve + n_P_Balance) + ".");
        }


            do {
            System.out.print("\n\n");
            System.out.print("DO YOU WANT TO continue Y/N => ");
            answer = stdin.readLine();
            reply = answer.charAt(0);
            if (reply =='n' || reply=='N')


                {
                System.out.print("\n\n");
                System.out.print("\t\t===================================================== " );
                System.out.println("\n\t\t\t THANK YOU for USING this PROGRAM" ); 
                System.out.println("\t\t Program Coding & Design By: Jake Rodriguez Pomperada " );
                System.out.print("\t\t===================================================== " );
                System.out.print("\n\n");
                System.exit(0);
            }
            else if (reply =='Y' || reply=='y')


                {
                // Second Part of the Code for Continuat
                //     ion of the execution of the code
                // to prevent errorneous computation if 
                //     you call again the main code of
                // the program you must assign a new var
                //     iable to avoid such problem.
                double n_P_Balance2=0.00, n_P_Interest2=0.00;
                double n_Final_Solve2=0.00;
                double n_Number_Years2=0;
                int a2=0;
                System.out.print("\n\n");
                System.out.print("\n\t =========================================");
                System.out.print("\n\t ==Savings Quikie Version 1.0===");
                System.out.print("\n\t =========================================");
                System.out.print("\n\n");
                System.out.print("ENTER PRESENT SAVINGS BALANCE :=> $ ");
                get_P_Balance2= stdin.readLine();
                n_P_Balance2 = Double.parseDouble(get_P_Balance2);
                System.out.print("ENTER INTEREST RATE PERCENT :=> ");
                get_P_Interest2= stdin.readLine();
                n_P_Interest2 = Double.parseDouble(get_P_Interest2);
                System.out.print("ENTER NUMBER OF YEARS :=> ");
                get_No_Years2= stdin.readLine();
                n_Number_Years2 = Double.parseDouble(get_No_Years2);
                System.out.print("\n");
                System.out.print(" === COMPUTED RESULTS === ");
                System.out.print("\n\n");


                    for (a2=1; a2<= n_Number_Years2; a2++) {
                    n_Final_Solve2 =n_Final_Solve2 + n_P_Interest2 * (n_Final_Solve2 + n_P_Balance2) /100;
                    System.out.println("Year No. "+ a2 + " => $ " + twoDigitsPastPoint.format(n_Final_Solve2 + n_P_Balance2) + ".");
                }
            }
        } while (reply== 'Y' || reply == 'y');
    }
} // End of Code


Mod edit: added code tags: :code:

Is This A Good Question/Topic? 0
  • +

Replies To: How could i convert this code to pascal and c?

#2 Tom9729  Icon User is offline

  • Segmentation fault
  • member icon

Reputation: 180
  • View blog
  • Posts: 2,641
  • Joined: 30-December 07

Re: How could i convert this code to pascal and c?

Posted 15 March 2008 - 07:24 PM

Do you know Pascal and C?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1