## Answered: - Does anyone has answers to these questions? Kindly send me

Does anyone has answers to these questions? Kindly send me the answers so I can compare my answers with them. Thank?you in anticipation.?

Course: Programming II

Comp 102

Assignment 1

Date: 8th March, 2016

Due Date: 15th March, 2016

Warm up Question #0 (Not to be submitted, will be a part of the evaluation quiz)

Study the following:

1. C Variables (rules and conventions)

2. C data types (all types and ranges)

3. C Modifiers for data types (with respect to part 2)

Question #1

Write a C program that evaluates the equations provided below. The program must prompt the user for inputs to the

equations and evaluate them based on the inputs. All variables on the right hand sides of the equations must be

inputted by the user. All variables, except for the variable a are floating-point values. a variable is an integer. The

constants used in the equations must be defined as constant macros (#defined constants). Error checking is not required

for your program. You do not need to check for faulty user input or dividing by zero.

Newton?s Second Law of Motion: force = mass * acceleration

Volume of a cylinder: volume_cylinder = PI * radius2 * height

Gravity: force = G * mass1 * mass2 / distance2, where G is the gravitational constant with value 6.67 * 10-11

Resistive divider: vout = r2 / (r1 + r2) * vin

Distance between two points:

distance = square root of ((x1 - x2)2 + (y1 - y2)2)

(note: you will need to use sqrt ( ) out of &lt;math.h&gt;)

General equation:

y = (73 / 12) - x * z + a / (a % 2) (recall: a is an integer; the 73 and 12 constants in the equation should be left as

integers initially, but explicitly ?type-casted? as floating-point values) [Google ?type-casting?]

For this assignment you are required to define, at a minimum, the functions provided below (note: these are your

required prototypes!):

1. double calculate_newtons_2nd_law (double mass, double acceleration)

2. double calculate_volume_cylinder (double radius, double height)

3. double calculate_gravity_force (double mass1, double mass2, double distance)

4. double calculate_resistive_divider (double resistance1, double resistance2, double vin)

5. double calculate_distance_between_2pts (double x1, double x2, double y1, double y2)

6. double calculate_general_equation (int a, double x, double z)

Question #2

Write a program to determine a professional baseball player's bonus at the end of a season. Bonus is calculated as:

1. All-Star Game appearance = \$25,000

2. Regular season MVP = \$75,000

3. World Series MVP = \$100,000

4. Gold Glove award = \$50,000

5. Silver Slugger award = \$35,000

6. Home run champ = \$25,000

7. Batting average champ = \$25,000

Prompt the user with a question related to each of the above categories. If the response is 'y' for yes, add the bonus to

the total, otherwise if the response is 'n' move to the next question. Use functions where appropriate.

Question #3

Write a Calorie Calculator program to determine what a person's caloric intake should be for a 24 hour span. The

program must make a decision about caloric intake, to maintain current body weight, based on gender, age, weight, and

height, and activity level. The Program must first compute the Basal Metabolic Rate (BMR). The BMR formula is the

following:

Women: BMR = 655 + (4.35 * weight in pounds) + (4.7 * height in inches) - (4.7 * age in years)

Men: BMR = 66 + (6.23 * weight in pounds) + (12.7 * height in inches) - (6.8 * age in years)

To determine total daily calorie needs, your program must apply the following guidelines:

1. Sedentary (little to no exercise): Calories = BMR * 1.2

2. Low activity: Calories = BMR * 1.375

3. Moderate activity: Calories = BMR * 1.55

4. High activity: Calories = BMR * 1.725

5. Extra activity: Calories = BMR * 1.9

Define functions where appropriate! Also, take input for age, gender, weight, and height values.

Question #4

Write a function to generate the following pyramid of numbers.

Question #5

Write a program that computes the cost of a long distance call. The cost of the call is determined according to the

following rate schedules.

A call made between 8:00 AM and 6:00 PM is billed at a rate of 6 rupees per minute.

A call made before 8:00 AM or after 6:00 PM is charged at a rate of 3.75 rupees.

According to this schedule, if a call starts at any time between 8:00 AM and 6:00 PM, and it ends after 6:00 PM then it

will be charged at the rate of 6 rupees per minute for the time before 6:00 PM and for the rest of the time the rate will

be 3.75 rupees per minute. For example if a call starts at 5:55 PM and ends at 6:05 PM then the charges on this call will

be 48.75 (30 rupees for first 5 minutes and 18.75 rupees for rest of the time).

Similarly if a call starts at the time before 8:00 AM but ends after 8:00 AM then it will be charged at the rate of 3.75

rupees for the time before 8:00 AM and for remaining minutes after 8:00 AM the rate will be 6 rupees per minute. For

example if a call starts at 7:49 AM and ends at 8:01 AM the charge on that call will be 47.25 rupees (41.25 for first 11

minutes and 6 rupees for last minute).

The input to the program will consist of the time the call started, and the length of call in minutes. The output will be the

cost of call. The time is to be input in 24-hours notation, so the time 1:30 PM is input as 13:30. The time will be input

using two variables of type int, one used for hour and other used for minutes. The number of the minutes for length of

the call will also be input as a value of type int.

The solution to this exercise can be divided into two parts as explained below. This will make your task easier.

Part 1: Calculating End Time of Call

Input: Start time (Hour, Minutes) and Length

Output: End time (Hour, Minutes)

In this part you need to calculate the end time of the call. This part of the program will need Start time of the call and

Length of the call as input. The output of this part of program is End Time of the call (The end time will also be

represented by two integer variables, one for hour and other for minutes). The output of this program will be needed in

the second part of the program which is described below.

Part 2: Calculating the Cost of Call

Input: End time (Hour, Minutes) ? Calculated in Part 1

Output: Cost of Call

The input to this part of the program will be the value of End Time calculated in part 1, as described above. Using the

variable values resulting from part 1, this part will calculate the final output of the program i.e. Cost of the call.

*Test your program for the following set of inputs, no need to test any other case.

Sample Output:

Enter starting hour: 3

Enter starting min: 45

Enter length: 63

Ending hour and min is 4: 48

Call charges are 236.25

_______________________________

Enter starting hour: 7

Enter starting min: 55

Enter length: 10

Ending hour and min is 8: 5

Call charges are 48.75

_______________________________

Enter starting hour: 7

Enter starting min: 49

Enter length: 12

Ending hour and min is 8: 1

Call charges are 47.25

_______________________________

Enter starting hour: 16

Enter starting min: 20

Enter length: 120

Ending hour and min is 18: 20

Call charges are 675.00

_______________________________

Enter starting hour: 21

Enter starting min: 20

Enter length: 15

Ending hour and min is 21: 35

Call charges are 56.25

_______________________________

Solution details:
STATUS
QUALITY
Approved

This question was answered on: Sep 18, 2020 Solution~0001185720.zip (25.37 KB)

This attachment is locked

We have a ready expert answer for this paper which you can use for in-depth understanding, research editing or paraphrasing. You can buy it or order for a fresh, original and plagiarism-free copy from our tutoring website www.aceyourhomework.com (Deadline assured. Flexible pricing. TurnItIn Report provided)

##### Pay using PayPal (No PayPal account Required) or your credit card . All your purchases are securely protected by .

STATUS

QUALITY

Approved

Sep 18, 2020

EXPERT

Tutor 