Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using a C++ Console Application, Complete the following task Task : a. Write the

ID: 3666378 • Letter: U

Question

Using a C++ Console Application, Complete the following task

Task:  

a.Write the definition of a struct named courseType which has four members: courseName of type string, courseID of type int, and credit of type int.

b.In the function main, create a struct variable course1 of type courseType, and initialize it with the following values:

            courseName: “Programming ”

     courseID: 34560 credit: 4

    

c.Write the definition of function printCourse to print the contents of a courseType variable.

d.In the function main, create a struct variable course2, and copy the contents of course1 to course2.

e.Change the member courseName of course2 to “Web Database Development” and change courseID of course2 by adding 100 to it.

f.Call function printCourse to output the values of course1 and course2.

g.Write the definition of a struct named studentType that has three members: studentName of type string, firstCourse of type courseType, and secondCourse of type courseType.  

h.In the function main, create variable student1 of type studentType, and initialize it with:

studentName:   “Courtney Allen” firstCourse:                 course1 secondCourse:               course2

           

i.Output the following information of student1:

    studentName

          courseName of student1’s firstCourse courseName, courseID and credit of student1’s secondCourse.

Explanation / Answer

#include<iostream>
#include<string>
using namespace std;

//a
struct courseType{
   string courseName;
   int courseID;
   int credit;
   };
//g
struct studentType{
   string studentName;
   courseType firstCourse;
   courseType secondCourse;
   };
//c     
void printCourse(courseType course) {
   cout<<course.courseName<<" "<<course.courseID<<" "<<course.credit<<endl;
   }
int main() {

   //b
   courseType course1 = {"Programming",34560,4};
   cout<"course1: ";
   printCourse(course1);
   //d
   courseType course2 = course1;
   //e
   course2.courseName = "Web Database Development";
   course2.courseID += 100;
   //f
   cout<<"course1: ";
   printCourse(course1);
   cout<<"course2: ";
   printCourse(course2);
  
   //h
   studentType student1 = {"Courtney Allen", course1, course2};
   //i
   cout<<"Student1 name: "<<student1.studentName<<endl;
   cout<<"student1 firstcourse: ";
   printCourse(student1.firstCourse);
   cout<<"student1 secondcourse: ";
   printCourse(student1.secondCourse);
return 0;
}

/*

OUTPUT:

Programming 34560 4
course1: Programming 34560 4
course2: Web Database Development 34660 4
Student1 name: Courtney Allen
student1 firstcourse: Programming 34560 4
student1 secondcourse: Web Database Development 34660 4

*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote