#include
#include
#include
using namespace std;
string ask(string prompt)
{
string input;
cout< getline(cin, input); return(input); } int ask_for_int(string prompt) { int input; while(1) { string response = ask(prompt); stringstream s(response); if(s>>input) return(input); cout<<"Invalid input."< } } int main() { cout<<"Slugging percentage calculator\n"< while(1) { int at_bats = ask_for_int("How many at bats? "); int singles = ask_for_int("How many singles? "); int doubles = ask_for_int("How many doubles? "); int triples = ask_for_int("How many triples? "); int home_runs = ask_for_int("How many home runs? "); int total_hits = singles + doubles + triples + home_runs; if( total_hits <= at_bats ) { double slg = ((double)( singles+(2*doubles)+(3*triples)+(4*home_runs)))/at_bats; cout<<"\nSLG = "< break; } cout<<"Invalid input.\nReason: the total hits exceeds the at bats."< cout<<"Please re-enter data."< } } Output Slugging percentage calculator How many at bats? 458 How many singles? 73 How many doubles? 36 How many triples? 9 How many home runs? 54 SLG = 0.847162
how to write a program that counts automorphic number from 1 to 999
Don't write, it is already written, google for 'cpp'.
Divide it by 1000.
there is no solution of this problem...........that's it..........
Its limited only by available memory.
On base percentage plus slugging percentage
On base percentage Plus Slugging percentage.
OPS stands for 'on base percentage plus slugging percentage' and is equal to (on base percentage + slugging percentage). If a player's on base percentage is .350 and slugging percentage is .500, the OPS is .850.
On-Base Plus Slugging. So it is a combination of a players On-Base Percentage (OBP) and their Slugging Percentage (SLG). For example, if a player has a .448 OBP and a .613 SLG they would have an OPS of 1.061.
On Base Percentage Plus Slugging Percentage
how to write a program that counts automorphic number from 1 to 999
By learning how to program on C+.
Don't write, it is already written, google for 'cpp'.
Divide it by 1000.
No.
OBP stands for On Base Percentage
You don't write an algorithm for a C++ program, unless you are documenting the C++ program after-the-fact. The normal procedure is to write the algorithm first, in a language independent fashion, and then translate that stated algorithm into C++ code, or into whatever language you wish.