The second level of problems requires the use of procedures and functions to manage larger programs.
Your Age in Days
Your problem is to write a program that will read in a person's birth date and the current date, and compute and display the person's age in days. The program will have to be interactive, to validate the dates it reads and to display results in a clear manner. When the dates given are incorrect, precise messages should be displayed. The program should be set up in such a way that it can compute repeatedly a number of ages and let the user decide when to terminate execution. The various output formats are mostly user’s prompts and error messages.Enter birth date in the form 11 21 91: Enter current date in the form 11 21 91: Today you are 2059 days old Want to compute another age? Incorrect value for month. Incorrect value for day. Incorrect value for year. Incorrect values for day and month. Incorrect values for month and year. Incorrect values for day and year. Incorrect values for day, month and year. You are not born yet!
What’s the Cost of My Mortgage?
The loan department of your bank still uses silly tables to determine what the monthly payment of a mortgage loan is going to be. The consumer association wants you to design a program to compute interactively monthly mortgage payments as well as the cost of such a loan over the first 5 years of the loan and the total cost of that loan.
In order to validate the input data, the loan amounts must be between $1,000 and $500,000, the loan interest must be between 3 and 20%, and the loan length must always be between 1 and 35 years. Although banks are a little secretive about the formulas they use to compute mortgage loans, we know that they base their computations on a monthly rate, that can be computed from the annual mortgage rate compounded twice a year. Loan rate tables show you that
(1 + Monthly Rate)12y = (1 + Annual Rate/2)2y
which leads to
(1 + Monthly Rate)6 = (1 + Annual Rate/2)
6 ´ log(1 + Monthly Rate) = log(1 + Annual Rate/2)
Monthly Rate = e log(1 + Annual Rate/2)/6 -1
Using this, we can compute the monthly payment.
Monthly Payment = Monthly Rate x Loan x (1 + Monthly Rate)12y
(1 + Monthly Rate)12y - 1
The program will use these formulas to compute and display the monthly payment of a given mortgage loan and to produce a detailed report of the payments over the first 5 years if needed. The output format used will be the following:Amount of mortgage loan: Annual interest rate: Length of mortgage loan (in years): Monthly payment: 999.99 Do you want a detailed report? Interest paid in 5 years: 12345.67 5 year balance: 23456.78 Total cost of mortgage loan: 34567.89
The detailed report format will be the following:Payment# Interest Capital Cum. Int. Balance 1 97.59 44.21 97.59 9955.79 2 97.16 44.65 194.75 9911.14
Solving the Quadratic Equation
The problem you have to solve now is the well-known quadratic equation. Remember its form?ax2 + bx + c = 0
Your program will accept the values of the three coefficients a, b, and c and compute the roots of the equation. The program will prompt the user for the three coefficients repeatedly, and stop when the user enters three zeroes for the coefficients. The program will distinguish between the various solutions and display the results with an appropriate message: one root, double root, real roots, complex roots, as well as an error message if coefficients a and b are zero while c is not. The output formats will be the following:Give values of three coefficients: Contradiction 2.0 = 0 One root = -25.0 Double root = 120.0 Root 1 = -2.0 Root 2 = -1.0 Complex roots = -18.0 +/- 12.4i
Pascal programming Related Interview Questions
|IBM Lotus Notes Interview Questions||Fortran Interview Questions|
|SQL Server 2008 Interview Questions||COBOL Interview Questions|
|IBM Lotus Domino Interview Questions||Dbase Interview Questions|
|MVC Framework Interview Questions||Delphi Interview Questions|
|Prolog Interview Questions||Lisp programming Interview Questions|
|Sql Server Dba Interview Questions||Asp Dot Net Mvc 4 Interview Questions|
|Object Oriented Analysis and Design Interview Questions|
Pascal Programming Tutorial
Computing: A Short Survey Of Some Applications
Programming Language: Pascal
Data And Actions
The Four Fundamental Forms In Pascal
Pascal With Bigger Blocks
Better Blocks: Procedures And Libraries
Pascal Data Structures
Algorithms To Run With
The Seven Step Method
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.