Question

In: Computer Science

I need to convert the following into C++. The general idea is to create an application...

I need to convert the following into C++. The general idea is to create an application that can support 10 ID's and 10 grades. It needs to calculate the grade average of said ID, and determine if it is an below or above a certain average, ergo A or C.

string[10] studentIDArray
int[10] gradeArray
int averageGrade

for(int i = 0; i < gradeArray; i++)
{
averageGrade += gradeArray[i]
}

averageGrade = averageGrade / sizeof(gradeArray)
for(int i = 0; i < studentIDArray; i++){
if(gradeArray[i] > averageGrade)
{
Output: studentIDArray[i] gradeArray[i] grade is A
}
else
{
Output: studentIDArray[i] gradeArray[i] grade is C
}

}

Solutions

Expert Solution

#include <iostream>

using namespace std;

int main()
{
  // assign with default to test

string studentIDArray[10]={"101","102","103","104","105","106","107","108","109","110"};

// assign with default to test

   int gradeArray[10] = {1,2,3,4,5,6,7,8,9,10};
   double averageGrade; // since average is double
  
   for(int i = 0; i < 10; i++)
   {
       averageGrade += gradeArray[i];
   }
  
   averageGrade = averageGrade / (sizeof(gradeArray)/sizeof(gradeArray[0])); // divide by size
  
   for(int i = 0; i < 10; i++){
       if(gradeArray[i] > averageGrade)
       {
// print id grade grades got
           cout<<studentIDArray[i]<<" "<<gradeArray[i] <<" grade is A"<<endl;
       }
       else
       {
           cout<<studentIDArray[i]<<" "<<gradeArray[i]<<" grade is C"<<endl;
       }
   }
   return 0;
}

/* OUTPUT */

/* PLEASE UPVOTE */


Related Solutions

I need an idea of Java code that will convert an integer (1 to 3,999) into...
I need an idea of Java code that will convert an integer (1 to 3,999) into roman numerals using if statements; arrays and loops sadly aren't allowed and that's all I can come up with.
C++ Hello .I need to convert this code into template and then test the template with...
C++ Hello .I need to convert this code into template and then test the template with dynamic array of strings also if you can help me move the function out of the class that would be great.also There is a bug where the memory was being freed without using new operator. I cant seem to find it thanks in advance #include using namespace std; class DynamicStringArray {    private:        string *dynamicArray;        int size;    public:   ...
C# I need working code please Write a console application that accepts the following JSON as...
C# I need working code please Write a console application that accepts the following JSON as input: {"menu": { "header": "SVG Viewer", "items": [ {"id": "Open"}, {"id": "OpenNew", "label": "Open New"}, null, {"id": "ZoomIn", "label": "Zoom In"}, {"id": "ZoomOut", "label": "Zoom Out"}, {"id": "OriginalView", "label": "Original View"}, null, {"id": "Quality"}, {"id": "Pause"}, {"id": "Mute"}, null, {"id": "Find", "label": "Find..."}, {"id": "FindAgain", "label": "Find Again"}, {"id": "Copy"}, {"id": "CopyAgain", "label": "Copy Again"}, {"id": "CopySVG", "label": "Copy SVG"}, {"id": "ViewSVG", "label": "View...
i need an informative speech on Cancer with its topic general purpose specific purpose central idea...
i need an informative speech on Cancer with its topic general purpose specific purpose central idea statement
Hi i need a c++ program that can convert charactor into numbers pseodocode user input their...
Hi i need a c++ program that can convert charactor into numbers pseodocode user input their name for example john every single charactor should have a value so it return correct result eg: j=2, o=1, h=7,n=2 and display these numbers if you may need any question to ask me, i will be very happy to answer them. Thanks! example project close but not accurate #include #include #include #include #include #include #include #include #define INPUT_SIZE 8 using namespace std; // Function...
Create an Java application that uses a class to convert number grades to letter grades and...
Create an Java application that uses a class to convert number grades to letter grades and another class for data validation. Specifications The Grade class should have only one Instance Variable of type int. Use a class named Grade to store the data for each grade. This class should include these three methods:   public void setNumber(int number)   public int getNumber()   public String getLetter() The Grade class should have two constructors. The first one should accept no parameters and set the...
Create a simple C++ application that will exhibit concurrencyconcepts. Your application should create two threads...
Create a simple C++ application that will exhibit concurrency concepts. Your application should create two threads that will act as counters. One thread should count up to 20. Once thread one reaches 20, then a second thread should be used to count down to 0. For your created code, provide a detailed analysis of appropriate concepts that could impact your application. Specifically, address:Performance issues with concurrencyVulnerabilities exhibited with use of stringsSecurity of the data types exhibited.
I need to create a code in C++ that first has a menu animation of game...
I need to create a code in C++ that first has a menu animation of game Pacman, a score label in the map, and a bar that have the lives of pacman in the map.
Convert the following C++ code into MIPS assembely. For testing I will be change the values...
Convert the following C++ code into MIPS assembely. For testing I will be change the values for q,y,x with few different values. //q -> $s0 //y -> $s1 //x -> $s2 int main(){ int q = 5; int y = 17; int x = 77; if ( q < 10){ cout << "inside if"; } elseif ( x > 0 || y < 10) { cout << "inside elseif"; } else { cout << "inside else"; } }
Create in C Sharp : Create an application that predicts the approximate size of a population...
Create in C Sharp : Create an application that predicts the approximate size of a population of organisms. The application should use text boxes to allow the user to enter the starting number of organisms, the average daily population increase (as a percentage), and the number of days the organisms will be left to multiply. For example, assume the user enters the following values in text boxes: Starting number of organisms: 2 Average daily increase: 30% Number of days to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT