C++ Program:
Given the following C++ code, complete it so that it keeps track of the Detroit Tigers record and winning percentage. The prompt asks the user for one of four options. Here are the options and what they do:
● “w” for win – this adds one to the number of wins and shows the record in a wins-losses format (for example, 4-3).
● “l” for loss – this adds one to the number of losses and shows the record in a wins-losses format.
● “p” for percentage – this calculates and shows the winning percentage. The formula is (wins / (wins + losses)).
● “x” to exit – this is the sentinel value.
This id the code given
// Your header comments here
#include <fstream>
#include <iomanip>
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
int main()
{
// Declare and initialize variables
// Your code here
char Option;
// Show application header
// Your code here
// Prompt for and read first option
cout << endl;
cout << "Enter an option "
<< "(w-win, l-loss, p-percentage, x-exit): ";
cin >> Option;
// Loop to process options
while (Option != 'x')
{
// Your code here
}
// Show closing message
// Your code here
// Pause system before application closes
system("pause");
}
#include <fstream>
#include <iomanip>
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
int main()
{
// Declare and initialize variables
int wins, losses;
char Option;
// Show application header
// Your code here
// Prompt for and read first option
cout << endl;
cout << "Enter an option "
<< "(w-win, l-loss, p-percentage, x-exit): ";
cin >> Option;
// Loop to process options
wins = 0;
losses = 0;
while (Option != 'x')
{
if(Option == 'w')
{
wins++;
cout<<endl<<"Win-Loss:
"<<wins<<"-"<<losses<<endl;
}
if(Option == 'l')
{
losses++;
cout<<endl<<"Win-Loss:
"<<wins<<"-"<<losses<<endl;
}
if(Option == 'p')
{
cout<<endl<<"Percentage: "<<(float) wins /
(wins+losses) * 100<<endl;
}
cout << endl;
cout << "Enter an option "
<< "(w-win, l-loss, p-percentage, x-exit): ";
cin >> Option;
}
cout<<endl<<"Thanks!";
// Show closing message
// Your code here
// Pause system before application closes
system("pause");
}
OUTPUT:
C++ Program: Given the following C++ code, complete it so that it keeps track of the...
Write a c++ program that simulates a million of games in craps. I am having a trouble getting to loop a million of times. I am trying to use a const for a million. This is the code so far. #include <iostream> #include <cstdlib>// contains prototypes for functions srand and rand #include <ctime>// contains prototype for function time #include <iomanip> using namespace std; int rollDice(); // rolls dice, calculates and displays sum void printstats(); int totroll = 0, games, point,...
Write a C++ console application that uses functions to calculate an employee’s salary.PART 1: Create a void function to print a menu asking the user to choose from the following options:1 - Annual salary2 - Monthly salary3 - Daily rate of pay4 – ExitThe void function only prints the menu. Format your cout statement to include the menu as displayed above.If the chosen option is 1- Annual Salary, ask the user for the number of hours they work perweek and...
Microsoft Visual Studios 2017 Write a C++ program that computes a student’s grade for an assignment as a percentage given the student’s score and total points. The final score must be rounded up to the nearest whole value using the ceil function in the <cmath> header file. You must also display the floating-point result up to 5 decimal places. The input to the program must come from a file containing a single line with the score and total separated by...
Hey, so i am trying to have my program read a text file using a structure but i also want to be able to modify the results(I kinda have this part but it could be better). I cant seem to get it to read the file(all the values come up as 0 and i'm not sure why because in my other program where it wrote to the txt file the values are on the txt file) i copied and pasted...
This is a C++ question need to complete project 2. attached the completed simple version of the program below but need the updated version which is listed in the project 2 outline Project 2 Rock, Paper, Scissors Updated Take the solution to Lab 3 and make sure the user enters a letter of R, P, or S and the computer generates a number between 0-2 and changes that number to a letter of R, P or S, using a switch....
The following C++ code include 3 files: Patient.h, Patient.cpp and Main.cpp. The program basically creates and stores patient records. The original code has everything in a single .cpp file. I tried to divide the code in 3 parts (Patient.h, Patient.cpp and Main.cpp), but it is giving me errors. Patient.h #ifndef PATIENT_H #define PATIENT_H #include <string> #include "Patient.cpp" using namespace std; class Patient{ private : string firstname; string lastname; string location; static int cnt; int id; public : Patient(string, string, string);...
Create a C++ project called lab3b and add the following source code init_struct.cpp to the project. #include <iostream> #include <string> #include <iomanip> using namespace std; // This program demonstrates partially initialized structure variables // PLACE YOUR NAME HERE struct taxPayer { string name; long socialSecNum; float taxRate; float income; float taxes; }; int main() { // Fill in code to initialize a structure variable named citizen1 so that // the first three members are initialized....
CODE IN C++ PLEASE INCLUDE A SCREENSHOT OF YOUR CODE Write a program that outputs the shortest distance from a given node to every other node in the graph. Do not change anything in the supplied code below that will be the Ch20_Ex3.cpp except to add documentation and your name. Please use the file names listed below since your file will have the following components: Note: Here are the files that I need graphType.h linkedList.h linkedQueue.h queueADT.h unorderedLinkedList.h weightedGraph.h #include...
Use Dev C++ for program and include all of the following. Im
lost.
Make sure the user enters a letter of R, P, or S and the
computer generates a number between 0-2 and changes that number to
a letter of R, P or S, using a switch. Make sure the user knows why
he/she has won or lost – print a message like “Paper covers Rock”
or “Scissors cuts Paper”.
Ask the user how many times he/she wants to...
c++, use the skeleton code to make a program of the
following
include <iostream> tinclude <string> using namespace std; class car public: //define your functions here, at least 5 private: string name; int mpg; double price int horsepower; // feel free to add more atributes int main() // create you objects, call your functions // define member functions here For this lab, write a program that does the following: Creates a class based on the car skeleton code (you may...