Question

Answer in C using basic C and loops.

ASSIGNMENT: Write a program that will display how many times a ball will bounce until its height is less than 1 inch. A ball

0 0
Add a comment Improve this question Transcribed image text
Answer #1

PROGRAM:


#include <stdio.h>
int main()
{
double height,cor;
printf("Enter the initial height of the ball (in feet) : ");
scanf("%lf",&height);
while(height<0.0)
{
printf(" The initial height of the ball must be a positive number.");
printf("\n Please re-enter the initial height of the ball (in feet) : ");
scanf("%lf",&height);
}
printf("Enter the ball\'s cofficient of restitution (0.0 to 1.0) : ");
scanf("%lf",&cor);
while(cor<0.0 || cor>1.0)
{
printf(" The cofficient of restitution must be between 0.0 and 1.0 inclusive.");
printf("\n Please re-enter the ball\'s cofficient of restitution (0.0 to 1.0) : ");
scanf("%lf",&cor);
}
if(cor>0.0 && cor<1.0)
{
printf("\nThe ball bounced x times.");
}
else if(cor==1.0)
{
printf("\nWith the cofficient of restitution equal to 1.0, the ball will bounce forever!");
}

return 0;
}

SCREENSHOTS:

main.c 1 { #include <stdio.h> 2 int main() 3-{ 4 double height, cor; 5 printf(Enter the initial height of the ball (in feet)Enter the initial height of the ball (in feet) : -5 The initial height of the ball must be a positive number. Please re-enter

Enter the initial height of the ball (in feet) : 5 Enter the balls cofficient of restitution (0.0 to 1.0) : 1 With the coffi

Add a comment
Know the answer?
Add Answer to:
Answer in C using basic C and loops. ASSIGNMENT: Write a program that will display how...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In C language using printf and scanf statements: Write a program to display a histogram based...

    In C language using printf and scanf statements: Write a program to display a histogram based on a number entered by the user. A histogram is a graphical representation of a number (in our case, using the asterisk character). On the same line after displaying the histogram, display the number. The entire program will repeat until the user enters zero or a negative number. Before the program ends, display "Bye...". The program will ask the user to enter a non-zero...

  • Write a visual basic program te a program to provide information on the height of a...

    Write a visual basic program te a program to provide information on the height of a ball thrown straight up into the air. Th 3. Wri e program should request as input the initial height, h feet, and the initial velocity, teet per second. The height of the ball (in feet) after t seconds is given by the formula tl6c feet. The five options to be provided by buttons are as follows: (a) Determine the maximum height of the ball....

  • Topics c ++ Loops While Statement Description Write a program that will display a desired message...

    Topics c ++ Loops While Statement Description Write a program that will display a desired message the desired number of times. The program will ask the user to supply the message to be displayed. It will also ask the user to supply the number of times the message is to be displayed. It will then display that message the required number of times. Requirements Do this assignment using a While statement.    Testing For submitting, use the data in the...

  • Lab 5-2 Nested Loops 2. Summation Of Numbers (using Nested While Loops) Part A: The program...

    Lab 5-2 Nested Loops 2. Summation Of Numbers (using Nested While Loops) Part A: The program will calculate and display the total of all numbers up to a specific number (entered by the user). Only positive numbers are allowed. Part B: User-controlled loop Part A Input Validation loop Part A: Summation loop Examples: When 5 is entered the program will calculate the total as 1+2+...+5 and display 15. When 2 is enterered the program will calculate the total as 1+2...

  • Hospital Charges ASSIGNMENT: Write a program to calculate and display the amount of the charges for...

    Hospital Charges ASSIGNMENT: Write a program to calculate and display the amount of the charges for a hospital stay. Create a global constant for the daily fee of a hospital room ($350.00/day). Ask the user for: The number of days spent in the hospital The amount of the medication charges The amount of the surgical charges The amount of the lab fees The amount of the physical rehabilitation charges Then, using functions, calculate the stay charges (number of days *...

  • Write a basic C++ program that will calculate a subject’s basal metabolic rate and estimate how...

    Write a basic C++ program that will calculate a subject’s basal metabolic rate and estimate how many days it will take to lose a specific number of pounds. The program will perform the following tasks: Declare variables and Named constants. Display “Welcome to <your name>’s Weight Loss Calculator” Prompt the user to enter the subject’s current weight. Prompt the user to enter the subject’s height in feet plus inches. Prompt the user to enter the subject’s age. Prompt the user...

  • In C using (printf and scanf) Write a program to ask the user for the weight...

    In C using (printf and scanf) Write a program to ask the user for the weight of a package, and display the shipping charges for the package. If the weight of the package is less than or equal to 0 pounds, inform the user and exit the program. The shipping charges are: Weight of Package Shipping Charge 2 pounds or less $1.25 Over 2 pounds but not more than 6 pounds $2.50 Over 6 pounds but not more than 10...

  • Using basic c++ write 2 separate codes for this assignment. Program #1 Write a program that...

    Using basic c++ write 2 separate codes for this assignment. Program #1 Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions. • void getScore() should ask the user for a test score, store it in the reference parameter variable, and validate it. This function should be called by the main once for each of the five scores to be entered. •...

  • This is in c programming using functions in visual studios Carpet Jolb A carpeting company wants...

    This is in c programming using functions in visual studios Carpet Jolb A carpeting company wants to estimate what it will cost a customer to have a room carpeted. They can carpet 65 sq. ft. of room space in 4 hours, and they charge $25.00 per hour as their labor rate Write a program to ask the user for the length of the room (in inches) to be carpeted, the width of the room (in inches) to be carpeted, and...

  • C Language <stdio.h> (FUNCTIONS) A concrete company wants to estimate what it will cost a customer...

    C Language <stdio.h> (FUNCTIONS) A concrete company wants to estimate what it will cost a customer to have a driveway poured. They can pour a 3 inch deep 200 sq. ft. driveway in 3 hours, and they charge $50.00 per hour as their labor rate. Write a program to ask the user for the length of the driveway (in feet), and the width of the driveway (in feet) to be poured. For both the length and width, make sure the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT