Question

struct nameType { string first; string last; }; struct studentType { nameType name; double gpa; };...

struct nameType {

string first;

string last;

};

struct studentType {

nameType name;

double gpa;

};

a. Write a program that declares an array of the studentType structure, size 10, name of your choice, and includes the following:

• Write a void function to request user input into each of the members of the studentType structure array. Be sure to include proper user prompts. Assume the entire structure array is filled. Write the prototype and the function definition.

• Call the function from main.

• Write a void function to output the information in the studentType structure array. Write the prototype and the function definition.

• Call the function from main.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include <cstring>

using namespace std;

struct nameType {

string first;

string last;

};

struct studentType {

nameType name;

double gpa;

};

int main(){

struct studentType stud[10];
int i;

cout << "enter Student details"<< endl;

for(i=0; i<10; i++){ //taking values from user

cout<<"First name\t";
cin >> stud[i].name.first;

cout<<"last name\t";
cin >> stud[i].name.last;


cout << "Enter GPA\t";
cin >> stud[i].gpa;
cout<<endl;
}

for(i=0; i<10; i++){ //printing values
cout << "Student firrst name \t "<<stud[i].name.first << endl;

cout << "Student last name \t "<<stud[i].name.last << endl;
cout << "Student GPA : \t" << stud[i].gpa<< endl;
}
return 0;

}

Add a comment
Know the answer?
Add Answer to:
struct nameType { string first; string last; }; struct studentType { nameType name; double gpa; };...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Consider the following statements: struct nameType { string first; string last; }; struct courseType { string...

    Consider the following statements: struct nameType { string first; string last; }; struct courseType { string name; int callNum; int credits; char grade; }; struct studentType { nameType name; double gpa; courseType course; }; studentType student; studentType classList[100]; courseType course; nameType name; Mark the following statements as valid or invalid. If a statement is invalid, explain why. student.course.callNum = "CSC230"; cin >> student.name; classList[0] = name; classList[1].gpa = 3.45; name = classList[15].name; student.name = name; cout << classList[10] << endl;...

  • Answer it by using c++ context. struct courseType struct studentType { { struct name Type {...

    Answer it by using c++ context. struct courseType struct studentType { { struct name Type { string first; string last; }; string name; int callNum; int credits; char grade; name Type name; double gpa; courseType course; }; student Type student; student Type classList[100]; course Type course; nameType name; Mark the following statements as valid or invalid. If a statement is invalid, explain why. a. student.name.last="Anderson"; b. classList[1].name = student; c. student.name = classList[10].name;

  • Please use C++ Chapter 9 defined the struct studentType to implement the basic properties of a...

    Please use C++ Chapter 9 defined the struct studentType to implement the basic properties of a student. Define the class studentType with the same components as the struct studentType, and add member functions to manipulate the data members. (Note that the data members of the class studentType must be private.) Write a program to illustrate how to use the class studentType. Struct studentType: struct studentType { string firstName; string lastName; char courseGrade; int testScore; int programmingScore; double GPA; }; An...

  • 1. 2. Given struct Sudent [ string firstName; string lastName double gpa, MovieData movie-new MovieData[10]: Write...

    1. 2. Given struct Sudent [ string firstName; string lastName double gpa, MovieData movie-new MovieData[10]: Write a statement that dynamically allocates an array to hold 100 students

  • I am struggling with a program in C++. it involves using a struct and a class...

    I am struggling with a program in C++. it involves using a struct and a class to create meal arrays from a user. I've written my main okay. but the functions in the class are giving me issues with constructors deconstructors. Instructions A restaurant in the Milky way galaxy called “Green Alien” has several meals available on their electronic menu. For each food item in each meal, the menu lists the calories per gram and the number of grams per...

  • Write a C++ Program In C++, struct is a reserved word. Define the struct fruitType. Write...

    Write a C++ Program In C++, struct is a reserved word. Define the struct fruitType. Write a program that declares a variable of type fruitType, prompts the user to input data about a fruit, and outputs the fruit data. You must insert the following comments at the beginning of your program and write our commands in the middle: Write a C++ Program: /* // Name: Your Name // ID: Your ID */ #include <iostream> #include <string> using namespace std; struct...

  • Consider the Tollowing class declaration: class student record public: int age; string name; double gpa; }:...

    Consider the Tollowing class declaration: class student record public: int age; string name; double gpa; }: Implement a void function that initiatizes a dynamic array of student records with the data stored in the file "university body.txt". The function has three formal parameters: the dynamic array "S db, the count, and the capacity. Open and close an ifstream inside the function. Remember, you must allocate memory for the initial size of the dynamic array using "new" inside this function. If...

  • The structure Car is declared as follows: struct Car { string carMake; string carModel; int yearModel;...

    The structure Car is declared as follows: struct Car { string carMake; string carModel; int yearModel; double cost; }; Write a definition statement that defines a Car structure variable initialized with the following data: Make: Ford Model: Mustang Year Model: 1968 Cost: $20,000 THEN Define an array of 25 of the Car structure variables

  • 1. Create a file that contains 3 rows of data of the form: First Name Middle...

    1. Create a file that contains 3 rows of data of the form: First Name Middle Name Last Name Month Day Year Month Day Year GPA. This file represents student data consisting of first name, middle name, last name, registration month, registration day, registration year, birth month, birth day, birth year, current gpa. ...or you may download the data file inPut.txt. inPut.txt reads:​​​​​​​ Tsia Brian Smith 9 1 2013 2 27 1994 4.0 Harper Willis Smith 9 2 2013 9...

  • struct Item { string name; int quantity; float cost; }; const int MAX_SIZE = 50; class...

    struct Item { string name; int quantity; float cost; }; const int MAX_SIZE = 50; class ManageInventory { public: ManageInventory() : count{0}, p_pInventoryItems {new Item*[size]} { } ManageInventory(int size) : size{size}, count{0}, p_pInventoryItems {new Item*[size]} { } ~ManageInventory(); void addItem(string name, int quantity, float cost); private: int size {MAX_SIZE}; int count; Item ** p_pInventoryItems; }; Write the definition for addItem. Use the new operator to dynamically create instances of type Item. Store pointers to inventory items in the inventoryItems array....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT