DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Re: Anyone can do this difficult C++ program

  1. #1
    HataSan Guest

    Re: Anyone can do this difficult C++ program


    Background

    A college records exam and coursework marks as percentages. The college requires
    a simple system for calculating overall marks, averages and for displaying
    these. For simplicity, you may assume that there is only a single course
    module, call CIS104, which as an examination worth 80% of the overall marks
    and a coursework worth 20% of the overall marks. There are approximately
    20 students on the course, but your solution should cater for a varying number
    of students up to a reasonable upper bound, which you should choose yourself.


    The coursework

    Write a program in C++ to assist the analysis of marks. The program should
    accept exam and coursework marks and calculate over all marks for each student
    and for the class a whole, the program should calculate the average overall
    mark and average examination and coursework.

    The program should also print a histogram, using ASCII characters if you
    find this easier (but graphics if you prefer), depicting the marks.

    An example fragment (for just the first four students' coursework) of a suitable
    histogram is depicted in Figure 1. An alternative (less attractive, but acceptable,
    that is, passable) version is depicted in Figure 2.


    xxx
    xxx
    xxx xxx
    xxx xxx xxx
    xxx xxx xxx
    xxx xxx xxx
    xxx xxx xxx xxx
    xxx xxx xxx xxx
    ------------------------- Student
    Tan Kar Kim Chu


    Figure 1: Attractive Histogram Fragment


    Student | Mark
    -------------------------
    Tan | ********
    Kar | ******
    Kim | *****
    Chu | **


    Figure 2: Attractive Histogram Fragment


    You may add additional features to the program if you wish. 20% of the marks
    are allocated to this.


  2. #2
    Join Date
    Jan 2012
    Posts
    1
    Code:
    #include<iostream.h>
    #include<conio.h>
    void main();
    {
    int a[50],b[50],c,p,x=0,y=0,z,d;
    float su[50];
    clrscr();
    cout<<"Enter the no of students(less than 50)=";
    cin>>c;
    for(p=1;p<=c;p++)
    {
    cout<<"Enter Examination marks of student no"<<p<<"=";
    cin>>a[p];
    }
    for(p=1;p<=c;p++)
    {
    cout<<"Enter course work of student no"<<p<<"=";
    cin>>b[p];
    }
    for(p=1;p<=c;p++)
    {
    su[p]=(a[p]+b[p]);
    cout<<"Total of student"<<p<<"="<<su[p]<<endl;
    x=x+a[p];
    y=y+b[p];
    cout<<"Percent="<<su[p]<<endl;
    }
    cout<<"Average (EXAM)="<<(x/c)<<endl;
    cout<<"Average (COURSEWORK)="<<(y/c)<<endl;
    cout<<"Average(TOTAL)="<<(x+y)/c<<endl;
    cout<<"Students \t Marks"<<endl;
    for(p=1;p<=c;p++)
    {
    z=su[p]/10.0;
    cout<<p<<"|"<<"\t \t";
    for(d=1;d<=z;d++)
    cout<<"*";
    cout<<endl;
    }
    getch();
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center