Question

Project 4 - Covers Chapters 1-5 The MS Society is raising money this year having an indoor walk-a-thon where participants eStudent learning outcomes: • input validation • text files program planning cout object #include directive data types • opera

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

#include <iostream>
#include <fstream>

using namespace std;

int main()
{
char name[80];
cout<<"Enter Full name: ";
cin.getline(name,sizeof(name));
int step;
int s[30];
int sum=0;
int count=0;
ofstream file;
file.open("AnonymousMSWalk.txt");
  
cout<<"Enter daily steps(-1 to exit)"<<endl;
while(step!=-1){
cin>>step;
if(step>=0 && step<65000){
s[count]=step;
sum+=step;
count++;
}
}
cout<<"Enter steps per mile:"<<endl;
int miles;
cin>>miles;
while(miles>2500 || miles<2000){
cout<<"Enter again, value between 2000 and 2500: ";
cin>>miles;
}
  
cout<<"\n\nTotal steps count = "<<sum;
double average=(double)sum/count;
cout<<"\nAverage steps per day = "<<average;
double milesWalked=(sum/miles);
cout<<"\nNumber of miles walked = "<<milesWalked;
double avgMiles=(double)(milesWalked)/count;
cout<<"\nAverage miles per day = "<<avgMiles<<endl;
int min=65001, max=-1;
for(int i=0;i<count;i++){
if(s[i]>max){
max=s[i];
}
if(s[i]<min){
min=s[i];
}
}
cout<<"Maximum steps = "<<max<<endl;
cout<<"Minimum steps = "<<min<<endl;
file<<"\n\nTotal steps count = "<<sum<<"\nAverage steps per day = "<<average
<<"\nNumber of miles walked = "<<milesWalked<<"\nAverage miles per day = "
<<avgMiles<<"\nMaximum steps = "<<max<<"\nMinimum steps = "<<min;
return 0;
}

screenshot of code

int main() { char name[80]; cout<<Enter Full name: cin.getline(name, sizeof(name)); int step; int s[30]; int sum=0; int coun

sample output

input Enter Full name: anonym iol Enter daily steps(-1 to exit) 5200 96000 4526 9632 12568 85632 -1 Enter steps per mile: 150

Sample File output

pp AnonymousMSWal... ! Total steps count = 57627 Average steps per day = 7203.38 Number of miles walked = 28 Average miles pe

Add a comment
Know the answer?
Add Answer to:
Project 4 - Covers Chapters 1-5 The MS Society is raising money this year having an...
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
  • Overview Module 3 Assignment 1 features the design of a pseudocode and a Python program that...

    Overview Module 3 Assignment 1 features the design of a pseudocode and a Python program that uses iteration to guess a number from 1 to 10. Each lab asks you to write pseudocode that plans the program’s logic before you write the program in Python and to turn in three things: 1) the pseudocode, 2) a screenshot of the output, and 3) the Python program. Instructions Write pseudocode for a Python program that uses iteration to guess a number from...

  • 1.     This project will extend Project 3 and move the encryption of a password to a...

    1.     This project will extend Project 3 and move the encryption of a password to a user designed class. The program will contain two files one called Encryption.java and the second called EncrytionTester.java. 2.     Generally for security reasons only the encrypted password is stored. This program will mimic that behavior as the clear text password will never be stored only the encrypted password. 3.     The Encryption class: (Additionally See UML Class Diagram) a.     Instance Variables                                                i.     Key – Integer...

  • For this project, you are tasked with creating a text-based, basic String processing program that performs...

    For this project, you are tasked with creating a text-based, basic String processing program that performs basic search on a block of text inputted into your program from an external .txt file. After greeting your end user for a program description, your program should prompt the end user to enter a .txt input filename from which to read the block of text to analyze. Then, prompt the end user for a search String. Next, prompt the end user for the...

  • This interactive program focuses on if/else statements, Scanner, and returning values. Turn in a file named...

    This interactive program focuses on if/else statements, Scanner, and returning values. Turn in a file named Budgeter.java. To use a Scanner for console input, you must import java.util.*; in your code. This program prompts a person for income and expense amounts, then calculates their net monthly income. Below are two example logs of execution from the program. This program’s behavior is dependent on the user input (user input is bold and underlined below to make it stand out and differentiate...

  • JAVA project PLEASE complete/ create project with comments in the programming explaining everything Text file Year...

    JAVA project PLEASE complete/ create project with comments in the programming explaining everything Text file Year of storm/ Name of storm/ mmdd storm started/ mmdd storm ended/ magnitude of storm/ //made up data 2004/Ali/1212/1219/1 2003/Bob/1123/1222/3 1980/Sarah/0123/0312/0 1956/Michael/1211/1223/4 1988/Ryan/0926/1019/ 1976/Tim/0318/1010/0 2006/Ronald/0919/1012/2 1996/Mona/0707/0723/1 2000/Kim/0101/0201/1 2001/Jim/1101/1201/3 Text file Class storm{ private String nameStorm; private int yearStorm; private int startStorm; private int endStorm; private int magStorm; public storm(String name, int year, int start, int end, int mag){ nameStorm = name; yearStorm = year; startStorm...

  • i need help with a mips program to to covert roman numerals to real numbers Lab 4: Roman Numeral Conversion Part A: Due...

    i need help with a mips program to to covert roman numerals to real numbers Lab 4: Roman Numeral Conversion Part A: Due Sunday, 19 May 2019, 11:59 PM Due Friday, 24 May 2019, 11:59 PM Part B: Minimum Submission Requirements Ensure that your Lab4 folder contains the following files (note the capitalization convention): o Diagram.pdf o Lab4. asm O README.txt Commit and push your repository Lab Objective In this lab, you will develop a more detailed understanding of how...

  • c++ please :) First, ask the user to enter a year (4-digit) and what week day...

    c++ please :) First, ask the user to enter a year (4-digit) and what week day does this year starts with (String) For example, the year 2018 starts with the week day "Friday". In this case, the calendar should start from January 1 which is Friday, 2018 Your program should produce a formatted calendar for the specified year and there should be a blank line after each month. Moreover, the month and the year should be centered over each month....

  • All those points need to be in the code Project 3 Iterative Linear Search, Recursive Binary...

    All those points need to be in the code Project 3 Iterative Linear Search, Recursive Binary Search, and Recursive Selection Sort Class River describes river's name and its length in miles. It provides accessor methods (getters) for both variables, toString() method that returns String representation of the river, and method isLong() that returns true if river is above 30 miles long and returns false otherwise. Class CTRivers describes collection of CT rivers. It has no data, and it provides the...

  • cs55(java) please Part 1: You are a programming intern at the student transfer counselor's office. Having...

    cs55(java) please Part 1: You are a programming intern at the student transfer counselor's office. Having heard you are taking CS 55, your boss has come to ask for your help with a task. Students often come to ask her whether their GPA is good enough to transfer to some college to study some major and she has to look up the GPA requirements for a school and its majors in a spreadsheet to answer their question. She would like...

  • Help Please on JAVA Project: Validating the input is where I need help. Thank you Requirements...

    Help Please on JAVA Project: Validating the input is where I need help. Thank you Requirements description: Assume you work part-time at a sandwich store. As the only employee who knows java programming, you help to write a sandwich ordering application for the store. The following is a brief requirement description with some sample output. 1. Selecting bread When the program starts, it first shows a list/menu of sandwich breads and their prices, then asks a user to select a...

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