Computer Science, asked by vsana6jigangel, 1 year ago

Create a Program that Uses Two Parallel One-Dimensional Arrays
In this exercise, you create a program that uses two parallel one-dimensional arrays. The program displays a shipping charge that is based on the number of items ordered by a customer. Store the maximum order amounts in a one-dimensional int array. Store the shipping charge amounts in a parallel one-dimensional int array. The program should allow the user to enter the number of items a customer ordered. It then should display the appropriate shipping charge. Use a sentinel value to stop the program. Save and then run the program. Test the program appropriately. The shipping charge scale is: Minimum Order: 1, 11, 51, 101. Maximum Order: 10, 50, 100, 99999. Shipping Charge: 15, 10, 5, 0.

Answers

Answered by vishnureddy
0
n this exercise, you create a program that uses two parallel one-dimensional arrays. Ms. Jenkins uses the grade table shown in Figure 11-61 for her Introduction to Programming course. She wants a program that displays the grade after she enters the total points earned. Store the minimum points in a one-dimensional int array and the maximum points in one-dimensional array. Store the grades in a one-dimensional char array. Test the program using the following amounts: 455, 210, 400, and 349. what I have so far is: #include #include using namespace std; int main() { //declare the arrays int minPoint[5] = {0, 300, 350, 400, 450}; char grade[5] = {'F', 'D', 'C', 'B', 'A'}; int total = 0; cout << "Enter the total amount of points earned(-1 to stop): "; cin >> total; //grade loop while (total != -1) { if (total >= 450) cout << "Grade is " << grade[4] << endl; else if (total >= 0 && total < 450) { for (int x = 0; x <= 3; x += 1) { if (total >= minPoint[x] && total < 400) { cout << "Grade is " << grade[x] << endl; break; } } //end loop } else cout << "Test score invalid" << endl; cout << "Enter the total amount of points earned(-1 to stop); " ; cin >> total; } return 0; } when I run the values of 455, 210, 300, and 349. The first two come up ok but the last two display F. What am I doing wrong?


Similar questions