Create a C++ project that lets the user to enter the credit score from 5 different agencies.
Use a sentinel value you choose. If the sentinel value is the first you enter, give a message “NO Credit score entered!”. Use a counter to keep the number of the Credit score entries and an accumulator for the total of all entries.
When the user finishes entering the credit scores, calculate the average and display it on the screen.
#include <iostream> using namespace std; int main() { double total = 0; int count = 0, score; while (true) { cout << "Enter credit score(-1 to exit): "; cin >> score; if (score == -1) { break; } total += score; ++count; } if (count == 0) { cout << "NO Credit score entered!" << endl; } else { cout << "Average credit score is " << total/count << endl; } return 0; }
Get Answers For Free
Most questions answered within 1 hours.