Вы находитесь на странице: 1из 14

BTEC HND in Electrical/Electronic & Mechanical Engineering

Unit / Module Assessment Lecturer Student Name Date Handed Over Initial Submission Date Student to Tick if Attempted Criteria Met? Grading Opportunity Assessor Feedback 25/03/2010 Date Due Re-Submission Date Unit 34: Programming Concepts Assignment 1 Developing a Structured Program in C++ to Compute the GPA (Grade Point Average) Dr. D. P. Chandima ID 07/05/2010

Initially

On Resubmission

P2 P3 P4 M2 M3 D1 D3 Assessed By(Name): Signature: Student Signature & Comments: Date:

Important Information for Students


Programming Concept Assignment 1 International College of Business and Technology

BTEC HND in Electrical/Electronic & Mechanical Engineering

The criteria each task relates to are shown against that task where possible. Please note that plagiarism is treated as a serious offence and therefore the work you produce must be individual and original although may work in groups in some instances (Please refer to Student Handbook on Plagiarism & Cheating). All sources of information must be referenced using Harvard referencing where a reference list/Bibliography should be included at the end of the assignment. Please note that the submission date given for this assignment is the final date that you can hand over the assignment. A one week grace period maybe extended with prior approval from the Program Manager Undergraduate. However, note that submissions handed in one week late will be graded lower (Please refer to the Student Handbook on Assessments - Late Submissions & Penalties). Assignments returned to students for re-working must be re-submitted within 10 days (Please refer to Student Handbook on Assignments Re-submission). Failure to re-submit the previously marked assignment with the re-submitted assignment will mean that results cannot be released for the respective unit. Please read, follow and reference both the contents of the unit outline and the grading criteria of the assignment before completing this assignment.

Plagiarism: While research and discussion are an essential part of an assignment, the deliberate copying of someone elses work or unacknowledged copying from printed or electronic sources is NOT permitted. You may be subject to disciplinary procedure if you do this. You should sign this sheet to show that you comply with these regulations. Students Signature: .. Students Comments: .... Date: .

Programming Concept Assignment 1

International College of Business and Technology

BTEC HND in Electrical/Electronic & Mechanical Engineering


Assessment has been internally verified for use.

Internal Verifier Name: Signature : Date Verified :

Grading Classification Pass Grade: Pass Grade is achieved by meeting all following Grade Descriptors Grade Code: P1.1 P1.2 Grade Descriptors identify and select appropriate predefined data types. use simple input/output and appropriate operators with the above identify and use appropriate selection structures and loop structures for the given task produce C++ programs to desired standards Examples / Indicative Characteristics int, double, float etc as appropriate cout and cin with appropriate operators If-else, for, while, do-while as appropriate

P1.3

P1.4

Source code and final executable code

Assignment 1 - Developing a Structured Program in C++ to Compute the GPA (Grade Point Average) Learning outcome to be achieved: Design and develop codes using structured programming methods.
Programming Concept Assignment 1 International College of Business and Technology

BTEC HND in Electrical/Electronic & Mechanical Engineering


Scenario: Ten (10) students sit for an examination. Each student offers ten (10) subjects. Each subject is a 2 credits subject. If the raw marks of these subjects for each student are made available to you. You are required to develop a structured computer program to achieve the following: Obtain the name and the registration number of each student from the user using the standard input device. Obtain the marks for the subjects for each student from the user using the standard input device. Note: Valid range of marks is 0 - 100. The marks of each subject should be converted to the appropriate grade (Grading of marks is given in Table 1 below). Compute the GPA for each student (Formula for calculating GPA is given below). Find out the highest GPA. Print the following information on the standard output device. o Name and registration number of each student. o Grade of each subject and the GPA of each student against the students name on separate Marks Range 85 100 75 84 70 74 65 69 60 64 55 59 50 54 45 49 40 44 35 39 0 34 lines.
Programming Concept Assignment 1 International College of Business and Technology

Grade A+ A AB+ B BC+ C CD F

Grade Point 4.2 4.0 3.7 3.3 3.0 2.7 2.3 2.0 2.0 2.0 0.0

BTEC HND in Electrical/Electronic & Mechanical Engineering


o Name of the student who has obtained the highest GPA and the highest GPA on a separate line. Table 1: Grading of marks Formula for calculating the GPA:

GPA=

( Grade Points obtained for the i


i =1 n i =1

th

subject ) ( Credits offered to the ith subject )


th

Credits offered to the i

subject

where n is the number of subjects offered by a student.

Things to be submitted The final submission should include the following: Hardcopy report containing program design and source code. Compiled executable program in a floppy disk.

References
Henkmans D C++ Programming for the Absolute Beginner (Premier Press, 2003) ISBN 1931841438

Liberty J and Jones B Sams Teach Yourself C++ in 21 Days (Pearson Education, 2005) ISBN 8129708485 Grade code P1.1 P1.2 P1.3 P1.4 P2.1 P2.2
Programming Concept Assignment 1

Assignment 1

Assignment 2

Final examination

International College of Business and Technology

BTEC HND in Electrical/Electronic & Mechanical Engineering


P2.3 P3.1 P3.2 P4.1 P4.2 P4.3 P4.4

Assignment 2: Modular Programming Flow Chart Set default values for the rectangle

Calculating the area of that

Calculating the perimeter of that

Programming Concept Assignment 1

International College of Business and Technology

BTEC HND in Electrical/Electronic & Mechanical Engineering


Allow user to change the values of rectangle

Error checking whether user enters a wrong selection for the choice

Closing the program

The source code

#include <iostream> using namespace std;

#include <iostream> using namespace std;


Programming Concept Assignment 1 International College of Business and Technology

BTEC HND in Electrical/Electronic & Mechanical Engineering


class CRectangle { int width, height; public: CRectangle (int,int); int area () {return (width*height);} int Perimeter () {return (width+height)*2;}

};

CRectangle::CRectangle (int a, int b) { width = a; height = b; }

int choice; int main () {

loop1:

cout << "\n\t*** Menu *** " <<"\n"; cout << "\n(1) Draw Rectangle " ;
Programming Concept Assignment 1 International College of Business and Technology

BTEC HND in Electrical/Electronic & Mechanical Engineering


cout << "\n(2) Area " ; cout << "\n(3) Perimeter " ; cout << "\n(4) Resize " ; cout << "\n(5) Quit " << "\n" ; cout << "\nEnter a Choice = "; cin >> choice;

if (choice == 1) { loop4: int width=13,height=4; int i=0; int j=0;

cout << "\n"; for( i = 1; i <= height; i++ ) { for ( j = 1; j <= width; j++ ) {cout << "*";} cout << endl; } cout << "\n";

goto loop1;

}
Programming Concept Assignment 1 International College of Business and Technology

BTEC HND in Electrical/Electronic & Mechanical Engineering

else if (choice == 2){ int width=13,height=4; CRectangle rectb(width,height); cout << "\nArea of Rectangel is: " << rectb.area() << endl; goto loop1; } else if (choice == 3) { int width=13,height=4; CRectangle rectb(width,height); cout << "\nPerimeter of Rectangel is: " << rectb.Perimeter() << endl; goto loop1; } else if (choice == 4) {

goto loop2;

} else if (choice == 5){ exit(1); } else if (choice != 1 || choice !=2 || choice != 3 || choice != 4 || choice != 5) {

cout << "\n***THE NUMBER YOU ENTERED IS NOT VALIED***" << "\n\t" << "Enter a valied selection to proceed:"<<"\n"; }

Programming Concept Assignment 1

International College of Business and Technology

BTEC HND in Electrical/Electronic & Mechanical Engineering


//Resizing

loop3: cout << "\n\t\t*** Menu *** " <<"\n"; cout << "\n(1) Draw Rectangle " ; cout << "\n(2) Area " ; cout << "\n(3) Perimeter " ; cout << "\n(4) Resize " ; cout << "\n(5) Quit " << "\n" ; cout << "\n\tEnter a Choice = "; cin >> choice;

if (choice == 1) {

goto loop3;

else if (choice == 2){ int width,height;

CRectangle rectb(width,height); cout << "\nArea of Rectangel: " << rectb.area() << endl; goto loop3;
Programming Concept Assignment 1 International College of Business and Technology

BTEC HND in Electrical/Electronic & Mechanical Engineering


} else if (choice == 3) { int width,height; CRectangle rectb(width,height); cout << "\nPerimeter of Rectangel: " << rectb.Perimeter() << endl; goto loop1; } else if (choice == 4) { loop2: int width,height; cout << "\nEnter The Height Of The Rectangle: "; cin >> width; cout << "Enter The Width Of Rectangle: "; cin >> height; CRectangle rect(width,height); int i=0; int j=0;

cout << "\n"; for( i = 1; i <= width; i++ ) { for ( j = 1; j <= height; j++ ) {cout << "*";} cout << endl; } cout << "\n";
Programming Concept Assignment 1 International College of Business and Technology

BTEC HND in Electrical/Electronic & Mechanical Engineering


goto loop3;

} else if (choice == 5){ exit(1); } else if (choice != 1 || choice !=2 || choice != 3 || choice != 4 || choice != 5) { cout << "\nThe number you entered is not in given menu" << "\n" << "please select correct value again." << "\n"; } goto loop3;

system("pause"); return 0; }

Programming Concept Assignment 1

International College of Business and Technology

BTEC HND in Electrical/Electronic & Mechanical Engineering

Programming Concept Assignment 1

International College of Business and Technology

Вам также может понравиться