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...
1. To understand the value of records in a programming language, write a small program in...
1. To understand the value of records in a programming language, write a small program in a C-based language that uses an array of structs that store student information, including name, age, GPA as a float, and grade level as a string (e.g., “freshmen, junior, senior” etc.). Also, write the same program in the same language without using structs. Note: Code and with output screenshots
The program you will be writing displays a weekly payroll report. A loop in the program...
The program you will be writing displays a weekly payroll report. A loop in the program should ask the user for the employee's number, last name, worked hours, hourly pay rate, state tax and federal tax rate. After data in entered and the user hits the enter key, the program will calculate gross an net pay, then displays all employee's payroll information, and ask for the next employees' information. if worked hour is more than 40, double pay the hours...
You are on a diet and you are writing a javascript program that determines whether or...
You are on a diet and you are writing a javascript program that determines whether or not you can treat yourself to an ice cream. Your program takes as input: 1. Number of calories you have taken so far that day. 2. Number of calories you are expecting to take later on that day (excluding the potential ice cream) 3. Number of calories you have burnt (or are expecting to burn) with exercise that day. 4. What is your goal...
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...
Program Specifications: You will be writing a Java program called ASCIIRabbit.java that will print the following...
Program Specifications: You will be writing a Java program called ASCIIRabbit.java that will print the following ASCII objects. There should be two blank lines between each shape and your output must match identically. Rabbit In A Hat -------------------- (^\ /^) \ V / (o o) ( (@) ) --------- | | | | | | _______ Rabbit Under A Hat -------------------- _______ | | | | | | --------- /\"/\ () * () ("")_("") Rabbit Wears A Hat ------------------ _______...
The following task does not involve writing program code: instead, you will be writing function signatures...
The following task does not involve writing program code: instead, you will be writing function signatures for hypothetical functions (you will be defining functions in subsequent tasks). For this task, you are presented with several 'hypothetical' functions. These aren't built-in Python functions: they are functions that you will have to define (i.e. implement, write) yourself later. however, you only need to write a signature for each hypothetical function listed here: toThePower(): takes two numbers e.g. x and y , and...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT