Sunteți pe pagina 1din 4

SN Kansagra School

Assignment 3: PROGRAMMING
Subject: Computer Application Standard: 9 Submission Date: 17th SEP 2019

1. WAP to find the number of days in the given month (take input of month (as int) from user)
2. Assume a runner runs 14 kilometers in 45 minutes and 30 seconds. Write a program that
displays the average speed in miles per hour. (Note that 1 mile is 1.6 kilometers.)
3.

4. WAP that converts Fahrenheit to Celsius


5. WAP that caluclates Simple Interest (S.I) given P, R and N.
6. WAP that calculates Compound Interest (C.I) using formula : p * ( 1 + r/n )nt [Assuming principal
(p), time (t), rate of interest (r) and the number of times the interest is compound (n)]
7. WAP to Convert feet into meter [One foot is 0.305 meter]
8. WAP to Convert pounds into kilograms [One pound is 0.454 kilograms]
9. Write a program that reads a three digit integer and adds all the digits in the integer. For
example, if an integer is 932, the sum of all its digits is 14.
[Hint: Use the % operator to extract digits, and use the / operator to remove the extracted digit.
For instance, 932 % 10 = 2 and 932 / 10 = 93.]
10. WAP that converts the seconds to minutes, hours, days and remaining seconds:
{HINT: First divide the input by 86400, if you you can get a number greater than 0 , this is the
number of days. 2. Again divide the remained number you get from the first calculation by
3600, this will give you the number of hours.
Then divide the remainder of your second calculation by 60 which is the number of Minutes
Finally the remained number from your third calculation is the number of seconds}
11. Write a program that calculates the energy needed to heat water from an initial temperature to
a final temperature. Your program should prompt the user to enter the amount of water in
kilograms and the initial and final temperatures of the water.
The formula to compute the energy is:
Q = M * (finalTemperature – initialTemperature) * 4184
where M is the weight of water in kilograms, temperatures are in degrees Celsius, and energy Q
is measured in joules.
12. Given an airplane’s acceleration a and take-off speed v, you can compute the minimum runway
length needed for an airplane to take off using the following formula:
length =v2 /2a
Write a program that prompts the user to enter v in meters/second (m/s) and the acceleration
a in meters/second squared (m/s2), and displays the minimum runway length.
13. Body Mass Index (BMI) is a measure of health on weight. It can be calculated by taking your
weight in kilograms and dividing by the square of your height in meters.
Write a program that prompts the user to enter a weight in pounds and height in inches and
displays the BMI. Note that one pound is 0.45359237 kilograms and one inch is 0.0254 meters.
14. Create a Loan Calculator:
Step 1: Prompt the user to enter the annual interest rate, the number of years, and the loan
amount
(The interest rate is commonly expressed as a percentage of the principal for a period of one
year. This is known as the annual interest rate.)

Step 2: The input for the annual interest rate is a number in percent format, such as 4.5%. The
program needs to convert it into a decimal by dividing it by 100. To obtain the monthly interest
rate from the annual interest rate, divide it by 12, since a year has 12 months. So, to obtain the
monthly interest rate in decimal format, you need to divide the annual interest rate in
percentage by 1200. For example, if the annual interest rate is 4.5%, then the monthly interest
rate is 4.5/1200 = 0.00375.

Step 3: Compute the monthly payment using this formula:

Step 4: Compute the total payment, which is the monthly payment multiplied by 12 and
multiplied by the number of years.

Step 5: Display the monthly payment and total payment


15. WAP that prints Weekday or Weekend based on the day (String) entered by user (using switch
case)
16. WAP that finds out the Chinese Zodiac sign for a given year. The Chinese Zodiac sign is based on
twelve-year cycle, with each year represented as an animal like – monkey, rat, tiger,etc..

Note: 1900 is the year of rat because 1900 % 12 = 4. [use switch case]
17. Do reasearch on this:
- A switch case variable can take which data types?
- If the keyword break is not used after a case is processed, what is the next statement to
be executed?
- Can you convert a switch statement to an equivalent if statement, or vice versa?
- What are the advantages of using a switch statement?
18. Write a program that prompts the user to enter an integer for today’s day of the week (Sunday
is 0, Monday is 1, …, and Saturday is 6). Also prompt the user to enter the number of days after
today for a future day and display the future day of the week. [using switch]
19. Write a program that prompts the user to enter three integers and display the integers in non-
decreasing order.
20. WAP that prints following menu to user and perfom computations accordingly:
+++++++++++++++++++++
Press 1: Addition
Press 2: Subtraction
Press 3: Multiplication
Press 4: Division
+++++++++++++++++++++
(Any other number -> exit the program)
[Note: no need to take inputs of numbers (operands) from user. Generate any random numbers
from 1-100 and do the computation]

Inputs:
There is only one input needed from user -> (integer) choice from 1 to 4. The operads need to
be generated by Math.random() method
21. (Find the number of days in a month) Write a program that prompts the user to enter the
month and year and displays the number of days in the month. For example, if the user entered
month 2 and year 2012, the program should display that February 2012 had 29 days. If the user
entered month 3 and year 2015, the program should display that March 2015 had 31 days.
22. (Palindrome number) Write a program that prompts the user to enter a three-digit integer and
determines whether it is a palindrome number. A number is palindrome if it reads the same
from right to left and from left to right. For example: 121 -> is palindrome
123 -> is not palindrome , 494 -> is palindrome
23. (Cost of shipping) A shipping company uses the following function to calculate the cost (in
dollars) of shipping based on the weight of the package (in pounds).

Write a program that prompts the user to enter the weight of the package and display the
shipping cost. If the weight is greater than 50, display a message “the package cannot be
shipped.”
24. (Compute the perimeter of a triangle) Write a program that reads three edges for a triangle and
computes the perimeter if the input is valid. Otherwise, display that the input is invalid. The
input is valid if the sum of every pair of two edges is greater than the remaining edge.
25. WAP that prints following menu to user and perfom computations accordingly:
+++++++++++++++++++++
Press ‘+’: Addition
Press ‘-’: Subtraction
Press ‘*’: Multiplication
Press ‘/’: Division
+++++++++++++++++++++
(Any other number -> exit the program)
[Note: no need to take inputs of numbers (operands) from user. Generate any random numbers
from 1-100 and do the computation]. Inputs:
There is only one input needed from user ->character input. The operads need to be generated
by Math.random() method
26. Write a program that prompts the user to enter an integer and determines whether it is
divisible by 5 and 6, whether it is divisible by 5 or 6, and whether it is divisible by 5 or 6, but not
both. [use switch case]
27. (Geometry: two circles) Write a program that prompts the user to enter the center coordinates
and radii of two circles and determines whether the second circle is inside the first or overlaps
with the first, as shown here:

(Hint 1: circle2 is inside circle1 if the distance between the two centers <= |r1 - r2| and circle2
overlaps circle1 if the distance between the two centers <= r1 + r2.)
(Hine 2: Find distance between two centers by squre-root of : (x2 – x1 )2 + (y2 – y1)2 )

Instructions:
1. All the questions are to be submitted in the Assignment book in the hand-written format.
2. Program to be typed and output to be printed and cmd Screenshot must be Pasted in
Assignment Book.
3.If you don’t submit the assignment on time.5M will be deducted from project. :-(

S-ar putea să vă placă și