Question

In: Computer Science

I'm not sure i understand sending parameters and reference and i think im doing it wrong....

I'm not sure i understand sending parameters and reference and i think im doing it wrong. In this code i'm trying to enter notas (grades) by user input into the exArrays, getting the promedio (average) and printing it on screen.

I've searched a lot of videos but they don't help. The lenguage is C++

void entrarNotas(int ex1Array[], int ex2Array[], int ex3Array[], int sizeSalon, char notaPara, float promedioPara)
{
   cout << "Entrar cuantos estudiantes hay en el salon" << " :";

   cin >> sizeSalon;

   for (int k = 0; k < sizeSalon; k++)
   {
       cout << "Entre las notas del estudiante " << ": " << k + 1;

       cin >> ex1Array[k] >> ex2Array[k] >> ex3Array[k] ;

   }

   for (int i = 0; i < sizeSalon; i++)
   {
      
       promedioPara = ex1Array[i] + ex2Array[i] + ex3Array[i];
       promedioPara = promedioPara / 3.0;
   }

   for (int i = 0; i < sizeSalon; i++)
   {
       if (promedioPara >= 90)
           notaPara = 'A';

       else if (promedioPara >= 80)
           notaPara = 'B';

       else if (promedioPara >= 70)
           notaPara = 'C';

       else if (promedioPara >= 60)
           notaPara = 'D';

       else          
           notaPara = 'F';
   }
}

void imprimir(int ex1Array[], int ex2Array[], int ex3Array[], int sizeSalon, char notaPara, float promedioPara)
{
   for (int k = 0; k < sizeSalon; k++)
   {
       cout << "Notas del estudiante" << ": " << k + 1 << ex1Array[k] << ", " << ex2Array[k] << ", " << ex3Array[k] <<", " << promedioPara <<", " << notaPara;

   }

}


int main()
{
   int ex1[40], ex2[40], ex3[40], nota;

   float promedio;

   entrarNotas(ex1, ex2, ex3, nota, promedio);

   imprimir(ex1, ex2, ex3);

   return 0;
}

Solutions

Expert Solution


/*
 *  C++ program
 */

#include <iostream>
using namespace std;

#define MAX 3

void entrarNotas(int ex1Array[], int ex2Array[], int ex3Array[], int sizeSalon, char notaPara[], float promedioPara[])
{
  float tempPromedio;

  for (int i = 0; i < sizeSalon; i++)
  {
    cout << "Entre las notas del estudiante " << i + 1 << ": ";
    cin >> ex1Array[i] >> ex2Array[i] >> ex3Array[i] ;
  }

  for (int i = 0; i < sizeSalon; i++)
  {
    
    tempPromedio = ex1Array[i] + ex2Array[i] + ex3Array[i];
    promedioPara[i] = tempPromedio / 3.0;
  }

  for (int i = 0; i < sizeSalon; i++)
  {
    if (promedioPara[i] >= 90)
      notaPara[i] = 'A';
    else if (promedioPara[i] >= 80)
      notaPara[i] = 'B';
    else if (promedioPara[i] >= 70)
      notaPara[i] = 'C';
    else if (promedioPara[i] >= 60)
      notaPara[i] = 'D';
    else          
      notaPara[i] = 'F';
  }
}

void imprimir(int ex1Array[], int ex2Array[], int ex3Array[], int sizeSalon, char notaPara[], float promedioPara[])
{
  for (int k = 0; k < sizeSalon; k++)
  {
    cout << "Notas del estudiante" << ": " << k + 1 << ex1Array[k] << ", " << ex2Array[k] << ", " << ex3Array[k] <<", " << promedioPara[k] <<", " << notaPara[k] << endl;
  }
}


int main()
{
  int ex1[MAX], ex2[MAX], ex3[MAX];
  int size;
  char nota[MAX];
  float promedio[MAX];
  
  cout << "Entrar cuantos estudiantes hay en el salon" << ": ";
  cin >> size;

  entrarNotas(ex1, ex2, ex3, size, nota, promedio);

  cout << endl;
  imprimir(ex1, ex2, ex3, size, nota, promedio);
  
  return 0;
}

Note: Drop comments, for queries.


Related Solutions

Hi! I have a homework question I'm not sure if I'm doing it correctly. Below is...
Hi! I have a homework question I'm not sure if I'm doing it correctly. Below is the information from the question and my answer in bold. Glass Company makes glass orders based on the customer specifications, so the company uses job costing to track costs. The company uses direct labor hours as the cost driver for manufacturing overhead application. Manufacturing overhead costs for the year:        $787,500 Usage of direct labor hours for the year:               225,000 Beginning Work-in-process, March 1 (Job 57)      $80,000 Beginning...
I just need 3 and 5. I am not sure what I am doing wrong. I...
I just need 3 and 5. I am not sure what I am doing wrong. I get different numbers every time. Superior Markets, Inc., operates three stores in a large metropolitan area. A segmented absorption costing income statement for the company for the last quarter is given below: Superior Markets, Inc. Income Statement For the Quarter Ended September 30 Total North Store South Store East Store Sales $ 4,800,000 $ 960,000 $ 1,920,000 $ 1,920,000 Cost of goods sold 2,640,000...
This is for an accounting assignment and I'm not sure where I'm going wrong. I'll copy...
This is for an accounting assignment and I'm not sure where I'm going wrong. I'll copy and paste what I have and the directions as best as possible. PLEEEASE HELP: June 22: Received a bill for $1,190 from Computer Parts and Repair Co. for repairs to the computer equipment. It's telling me my rep and maintenance expense is wrong. I entered: Repairs & Maint. Expense 1190 Accounts payable 1190 It's for Byte of Accouting. What else would this transaction be...
I'm doing this homework on relativity and I'm not very good at it. :( I keep...
I'm doing this homework on relativity and I'm not very good at it. :( I keep getting things wrong or confused in my head. Please help me to understand this! Thank you in advance! 3. Person A is at rest with a light clock. Person B is in a car moving to the left (as seen by Person A with a light clock). Discuss how each person will perceive time. Use algebra to find the time measured by Person A...
I need to show work, and mainly understand what I'm doing 1) Harrison Co. issued 15-year...
I need to show work, and mainly understand what I'm doing 1) Harrison Co. issued 15-year bonds five years ago at a coupon rate of 6 percent. The bonds make semiannual payments. If the YTM on these bonds is 5 percent, what is the current dollar price assuming a $1,000 par value? A. $ 750.76 B. $ 845.56 C. $ 1077.95 D. $ 451.66 2)  The Timberlake-Jackson Wardrobe Co. has 5 percent coupon bonds on the market with 7 years left...
What am i doing wrong. I want for the program to run through then when it...
What am i doing wrong. I want for the program to run through then when it gets to "do you want to play again?enter yes or no" if they choose yes I want it to run again if they choose no then end. def play(): print("Welcome to the Game of Life!") print("A. Banker") print("B. Carpenter") print("C. Farmer") user_input = input("What is your occupation? ").upper() if user_input == "A": money = 100 elif user_input == "B": money = 70 elif user_input...
Pointers is a difficult concept for many students.  I'm not sure how to make students understand the...
Pointers is a difficult concept for many students.  I'm not sure how to make students understand the concept better. In an attempt to have you try to understand pointers, I'm going to ask you to write a paper that summarizes the chapter (or an online resource) that may help you understand the concept of pointers. Include the following topics in the paper. Include illustrations either from the book, or an online source or your own illustration. Come up with an introduction...
I'm doing a experiment for organic chemistry. I'm extracting amino acids from lentils and quinoa. I...
I'm doing a experiment for organic chemistry. I'm extracting amino acids from lentils and quinoa. I know which amino acids are in them. I need help on what to write for the items below. Introduction or Abstract – Background – . Results and Discussion – Conclusion – . Future work – ”
I get errors in my merge method and Im not sure how to fix it to...
I get errors in my merge method and Im not sure how to fix it to make the code work public class OrderedApp1 { public static void main(String[] args) {    int maxSize = 100; // array size int searchKey = 55; OrdArray1 arr, a1, a2, a3; // reference to arrays arr = new OrdArray1(maxSize); // create the arrays a1 = new OrdArray1(maxSize); a2 = new OrdArray1(maxSize); a3 = new OrdArray1(maxSize);    //int a3[] =new int [ a1.length + a2.length];...
One part of this question I am getting wrong. I'm assuming it's the test statistic? I...
One part of this question I am getting wrong. I'm assuming it's the test statistic? I got 1 for Question C, and I got 5.432 for question b, and I got B for question C. An undergraduate student performed a survey on the perceived physical and mental health of UBC students for her term project. She collected information by asking students whether they are satisfied with their physical and mental health status. 129 male and 157 female UBC students were...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT