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.
classList[j].name = name;
Assume the declarations of the previous exercise. Write C++ statements that do the following:name: Programming I
callNum: 13452
credits: 3
grade: ""
A.
a. student.course.callNum = "CSC230"; is invalid because callNum is a integer variable so cannot store string data.
b. cin >> student.name; is invalid because we cannot direct access name through student rather we should write student.course.name.name belongs to coursetype structure.
c. classList[0] = name; is invalid because it has no meaning.we can write like classList[0].name.first/last=" *****";
d. classList[1].gpa = 3.45; is valid.
e. name = classList[15].name; it is invalid because we cannot name = some thing rather we should write name.any member of name=something.
f. student.name = name; it is invalid because we are assigning value to a member through a variable of that structure and not to the direct variable.
g. cout << classList[10] << endl; it is invalid because cout statement will print which member of classList[10] is not specified
h. for(int j = 0; j < 100; j++)
classList[j].name = name; it is invalid because again there is no member is specified for name variable of name type structure to assign a value. classList[j].name.?
B.
a.
callNum: 13452
credits: 3
grade: ""
answer. student.course.name="prog";
student.course.callNum=222;
student.course.credits=3;
student.course.grade=' ';
b. In the array classList, initialize each gpa to 0.0.
answer. for(int j = 0; j < 100; j++)
classList[j].gpa =0;
c. Copy the information of the thirty-first component of the array classList into student.
answer. student.gpa=classList[31].gpa;
d. Update the gpa of the tenth student in the array classList by adding 0.75 to its previous value.
answer. classList[10].gpa = classList[10].gpa +0.75 ;
Consider the following statements: struct nameType { string first; string last; }; struct courseType { string...
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;
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 following is solved using C++ in Vocareum: In this problem, you will be prompting a student for grades and credits for courses taken. From that, you will calculate a GPA. This site: http://www.back2college.com/gpa.htm shows you how to calculate a GPA. Keep prompting the student if they want to add more courses. IMPORTANT NOTES! The course name is prompted for, but nothing is done with it. We are just using the grades A, B, C, D, and F so you...
Find the problems with this program #include <iostream> using namespace std; struct Student { string name; int grade; } int main() { struct Student mary; Mary:name = "Mary"; Mary:grade = 100; cout << mary:name " got a " << mary:grade << endl; return 0; }
Rework this project to include a class. As explained in class, your project should have its functionalities moved to a class, and then create each course as an object to a class that inherits all the different functionalities of the class. You createclass function should be used as a constructor that takes in the name of the file containing the student list. (This way different objects are created with different class list files.) Here is the code I need you...
Program 5 Due 10/25 C-String and Two-dimensional Array Use An input data file starts with a student's name (on one line). Then, for each course the student took last semester, the file has 2 data lines. The course name is on the first line. The second line has the student's grade average (0 to 100) and the number of credits for the course Sample data: Jon P. Washington, Jr. Computer Science I 81 4 PreCalculus 75 3 Biology I 88...
Using C++, fix the following code so that (1) Change the student array storage part so that the data is loaded from a file "students.txt". Use an appropriate data termination flag. (2) Sort the student array in ascending order of GPA using insertion sort. Print the sorted array (3) Sort the student array in ascending order of ID using insertion sort. Print the sorted array (4) Illustrate Binary search for a particular ID that would be found and one...
Write the functions needed to complete the following program as described in the comments. Use the input file course.txt and change the mark of student number 54812 to 80. /* File: course.cpp A student's mark in a certain course is stored as a structure (struct student as defined below) consisting of first and last name, student id and mark in the course. The functions read() and write() are defined for the structure student. Information about a course is stored as a...
/* Implementation of the main() method of the program. */ #include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; class Student { public: // default constructor Student() { studentID = 0; studentFirst = "First"; studentMiddle = "Middle"; studentLast = "Last"; } void SetStudentID(int number) { studentID = number; } void SetStudentFirst(string name) { studentFirst = name; } void SetStudentMiddle(string name) { studentMiddle =...
Hello I need help fixing my C++ code. I need to display in the
console the information saved in the file as well have the content
saved in the file output in a fixed position like the screenshot.
Thanks.
CODE
#include<iostream>
#include<fstream>
#include<iomanip>
using namespace std;
//main function
int main()
{
//variable to store student id
int id;
//variables to store old gpa(ogpa), old course
credits(occ), new course credits(ncc), current gpa(cur_gpa),
cumulative gpa(cum_gpa)
float ogpa,...