Question

In: Computer Science

You are writing a small program that records a swimmers swim time for a 100 Free...

You are writing a small program that records a swimmers swim time for a 100 Free Style event, compares it to the best time, and displays back if swimmer improved or added time. The swim time is entered in seconds. Prompt user to enter their best time before an event and current swim time and then display message if user improved or added time and by how many seconds. It's c++ program and use iostream header.

Solutions

Expert Solution

CODE:

#include<iostream>

using namespace std;

//main method
int main(){
float bestTime;
float currentTime;
float changeTime;

//asking the user to enter the best time
cout<<"Enter the swimmer's best swim time in seconds: ";
cin>>bestTime;
//asking the user to enter the current time
cout<<"Enter the swimmer's current swim time in seconds: ";
cin>>currentTime;

//calculating the change in time
changeTime = currentTime - bestTime;

//if the change in time was positive the swimmer added time
if(changeTime > 0){
cout<<"\nThe user added time: "<<changeTime<<" seconds"<<endl;
}else if(changeTime < 0){
//if the changeTime is negative the user improved time
cout<<"\nThe user improved time: "<<changeTime<<" seconds"<<endl;
}else if(changeTime == 0){
//if the change time is 0 the user maintained time
cout<<"\nThe user maintained time"<<endl;
}
return 0;
}

______________________________________________

CODE IMAGES:

____________________________________________

OUTPUT:

_____________________________________________

Feel free to ask any questions in the comments section
Thank You!


Related Solutions

In the 4x100 medley relay event in swimming, four swimmers swim 100 yards, each using a...
In the 4x100 medley relay event in swimming, four swimmers swim 100 yards, each using a different stroke. The four medley relay swimmers for a college team preparing for their conference championships have the following summary statistics (in seconds) for the four strokes: 1(backstroke) - Expected Value = 49 ; Stand. Dev = 0.34 2(breaststroke) - Expected Value = 54.76 ; Stand. Dev = 0.34 3(butterfly) - Expected Value = 48.5 ; Stand. Dev. = 0.21 4(freestyle - Expected Value...
Suppose we are writing a C++ program for the sales department of a small company. The...
Suppose we are writing a C++ program for the sales department of a small company. The department has 4 sales person and is selling 5 products. The program will allow the input of each sale made (sales person, product, sales amount). The program will also allow a user to see the sales made by a particular sales person or the sales on a particular product. Requirement of the Program: 1. Using a 2-D array as a data structure for storing...
You will be writing a small bank application. There will be two applications to this project...
You will be writing a small bank application. There will be two applications to this project – a client and a teller / administrative application with different functionalities between the two. As their names suggest, the client application will be tailored for customers of the bank, and the other for the employees of the bank. For your client side application, a client should be able to “log into” the program by providing a social security number. The program should only...
You are writing a program for an architectural firm that needs to enter the areas of...
You are writing a program for an architectural firm that needs to enter the areas of all the rooms in a building project they’re working on. Some rooms are square, some are round, and some are rectangular. Each room in the building has an ID number to help prevent adding the same room more than once. The program needs to prompt the user for the room ID number, the shape of the room, and the dimensions needed to calculate the...
in python You will be writing a program that can be used to sum up and...
in python You will be writing a program that can be used to sum up and report lab scores. Your program must allow a user to enter points values for the four parts of the problem solving process (0-5 points for each step), the code (0-20 points), and 3 partner ratings (0-10) points each. It should sum the points for each problem-solving step, the code, and the average of the three partner ratings and print out a string reporting the...
To earn full credit, program must be free of syntax, run-time, and logic errors; include program...
To earn full credit, program must be free of syntax, run-time, and logic errors; include program comments; use reasonable readable variable names and prompts. To include variables in the input prompt, you must use concatenation character (+). For example: assume you already asked for input of employee's first name and last name (they are stored into variables FirstName and LastName, then use this prompt to ask for employee's weekly hours which includes the employee's full name in the input statement....
In python make a simple code. You are writing a code for a program that converts...
In python make a simple code. You are writing a code for a program that converts Celsius and Fahrenheit degrees together. The program should first ask the user in which unit they are entering the temperature degree (c or C for Celcius, and f or F for Fahrenheit). Then it should ask for the temperature and call the proper function to do the conversion and display the result in another unit. It should display the result with a proper message....
You will be writing a C program to test the data sharing ability of a thread...
You will be writing a C program to test the data sharing ability of a thread and process. Your C program will do the following: 1. Your parent program will have three variables: int x,y,z; which to be initialized as 10, 20, and 0, respectively. 2. parent creating child: parent will create a child by fork() and the child will perform z = x+y (i.e., add x and y and store the results in z). parent will wait for child...
***USING JAVA Scenario: You will be writing a program that will allow a user to find...
***USING JAVA Scenario: You will be writing a program that will allow a user to find and replace misspelled words anywhere in the phrase, for as many words as the user wishes. Once done (see example runs below), the program will print the final phrase and will show the Word Count, Character Count, the Longest Word and the Shortest Word. Requirements: Do not use Arrays for this assignment. Do not use any String class methods (.phrase(), replace methods, regex methods)...
For this assignment you will be writing a program that evaluates some PostScript® commands. Specifically, you...
For this assignment you will be writing a program that evaluates some PostScript® commands. Specifically, you will be using a special version of a linked-list, called a Stack. Stacks are linear structures that are used in many applications. In fact, Java's runtime environment (JRE) uses a stack to evaluate Java's byte-code. You can learn more about Stacks from this URL: Tutorialspoint - Stack (Links to an external site.) The stack description above uses an array implementation for examples. You will...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT