Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4106
Number of posts: 14016

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
New program Posted by vyirus on 13 Jan 2013 at 12:19 PM
hello there, am new at sortoff new into the pascal environment and would love to get some assistance in that please. i have to create a program that will allow the entry of 10 students’ name, sex and grade which should display the percentage of students who got a grade of 50 or more.The Percentage of male students getting 50 or above together with the percentage of female students getting 50 or above.The program should also print the female with the highest average and the male with the highest average.
please help me since this is puzzling me and in urgent need of submission. thanking the person who helps with this asap!!
Report
Re: New program Posted by Pelle-48 on 13 Jan 2013 at 2:14 PM
You should use a pascal record structure like this:

http://pascal-programming.info/lesson11.php
Report
Re: New program Posted by vyirus on 13 Jan 2013 at 3:23 PM
that is d code i started with so far but am getting alot of problems:

program Grading_System;

uses
crt;

var
ClassNames : array[1..10] of string[20];
ClassGen : array[1..10] of string[20];
ClassAvg : array[1..10] of integer;
LoopCounter : integer;
NumberOfNames : integer;
sum:integer;
average: real;

begin
clrscr;
write('How many names are you entering (max 10)? ');
readln(NumberOfNames);

{Input Names, Grades and Gender}
LoopCounter := 1;
while LoopCounter <= NumberOfNames do
begin
writeln;
writeln('Enter Name: ',LoopCounter);
readln(ClassNames[LoopCounter]);
writeln;
writeln('Enter Gender: ',LoopCounter);
readln(ClassGen[LoopCounter]);
writeln;
writeln('Enter Average: ',LoopCounter);
readln(ClassAvg[LoopCounter]);
LoopCounter := LoopCounter + 1;
end;

{Print out names}
writeln('Here is the list of names');
LoopCounter := 1;
while LoopCounter <= NumberOfNames do
begin
writeln(ClassNames[LoopCounter],' : ',ClassGen[LoopCounter],' : ',ClassAvg[LoopCounter]);
LoopCounter := LoopCounter + 1;
end;
readln;

{Students with 50+ average}
writeln('Here is the percentage of students with 50+ average');
LoopCounter := 1;
while LoopCounter <= NumberOfNames do
begin
if ClassAvg[10] >= 50 then
sum := 0;
sum := sum + ClassAvg[10];
average := sum / 100;
writeln('Percentage of Students with 50+ average is: ',average:10:2,'%');
LoopCounter := LoopCounter + 1;
end;
readln;

end.
Report
Re: New program Posted by Actor21 on 17 Jan 2013 at 2:09 PM
(*
i have to create a program that will
   allow the entry of 10 students’ name, sex and grade

which should display :
   the percentage of students who got a grade of 50 or more.
   The Percentage of male students getting 50 or above.
   The percentage of female students getting 50 or above.
   The the female with the highest average
   The male with the highest average.
*)

program Grading_System ;
(*
uses crt ;
*)
var
   ClassNames     : array[1..10] of string[20] ;
   ClassGen       : array[1..10] of char ;
   ClassAvg       : array[1..10] of integer ;
   LoopCounter    : integer ;
   NumberOfNames  : integer ;
   sum            : integer ;
   average        : real ;

begin
   (*
   clrscr ;
   *)
   write('How many names are you entering (max 10)? ') ;
   readln(NumberOfNames) ;
   
   
   {
      Input Names, Grades and Gender
   }
   for LoopCounter := 1 to NumberOfNames do begin
      writeln ;
      writeln('Enter Name: ',LoopCounter) ;
      readln(ClassNames[LoopCounter]) ;

      repeat
         writeln ;
         writeln('Enter Gender: ',LoopCounter) ;
         readln(ClassGen[LoopCounter]) ;
      until ClassGen[LoopCounter] in ['F','M'] ;

      writeln ;
      writeln('Enter Average: ',LoopCounter) ;
      readln(ClassAvg[LoopCounter])
   end ;
   
   {
      Print out names
   }
   writeln('Here is the list of names') ;
   for LoopCounter := 1 to NumberOfNames do
      writeln(ClassNames[LoopCounter]:20, ' : ',ClassGen[LoopCounter],' : ',ClassAvg[LoopCounter]:5) ;
   readln ;
   
   {
      Students with 50+ average
   }
   sum := 0 ;
   for LoopCounter := 1 to NumberOfNames do
      if ClassAvg[LoopCounter] >= 50 then
         sum := sum + 1 ;
   average := 100.0 * sum / NumberOfNames ;

   writeln('Percentage of Students with 50+ average is: ', average:0:2,'%') ;
   readln
end.



Report
Re: New program Posted by vyirus on 17 Jan 2013 at 5:43 PM
thank you very much for your assistance, i just had to add in piece of the same code you had below to get for the males with 50+ average but it's working like a charm. I can't express my thanks but i really do appreciate you help much.
Report
Re: New program Posted by vyirus on 17 Jan 2013 at 7:32 PM
please help me with this. i have to find the gender with the highest number. both male and female that has the highest value, so i came up with this part of the code but am getting the same value for both male and female:

{
Female and Male with highest value
}
high := ClassAvg[1] ;
low := ClassAvg[1] ;

begin
if (ClassAvg[LoopCounter] > high) and (ClassGen[LoopCounter] = 'M') then
high := ClassAvg[LoopCounter] ;

if (ClassAvg[LoopCounter] < low) and (ClassGen[LoopCounter] = 'M') then
low := ClassAvg[LoopCounter] ;

if (ClassAvg[LoopCounter] > high) and (ClassGen[LoopCounter] = 'F') then
high := ClassAvg[LoopCounter] ;

if (ClassAvg[LoopCounter] < low) and (ClassGen[LoopCounter] = 'F') then
low := ClassAvg[LoopCounter] ;
end;
writeln('Male with highest grade is: ',ClassNames[LoopCounter],' - ',ClassGen[LoopCounter],' : ',high) ;
readln ;
writeln('Female with highest grade is: ',ClassNames[LoopCounter],' - ',ClassGen[LoopCounter],' : ',high) ;
readln
Report
Re: New program Posted by Actor21 on 17 Jan 2013 at 10:09 PM
This is a fragment. I have not had time to compile and test it.

var
   .
   .
   .
   Marker : char ;
   Index  : integer ;
   GenStr : string[6] ;

begin
   .
   .
   .
   {
      Female and Male with highest value
   }
   Marker := 'F' ;
   while Marker <= 'M' do begin
      if Marker = 'F' then
         GenStr := 'Female'
      else
         GenStr := 'Male' ;

      Index := 0 ;
      Max   := 0 ;
      for LoopCounter := 1 to NumberOfNames do begin
         if (ClassGen[LoopCounter] = Marker) and (ClassAvg[LoopCounter] > Max) then begin
            Max   := ClassAvg[LoopCounter] ;
            Index := LoopCounter
         end         
      end ;

      if Index = 0 then
         writeln ('There are no ', GenStr, 's in the class.')
      else
         writeln (ClassNames[Index], ' with an average of ',
                  ClassAvg[Index], ' is the highest ranking',       
                  Genstr, ' in the class.') ;

      Marker := 'M'
   end ;

Report
Re: New program Posted by vyirus on 18 Jan 2013 at 3:48 PM
thank you very much but i have to get both gender; male and female with the highest grade of the program. i have used what you have created and am trying to adjust it but am getting an infinity loop. just keep going, please assist me in that but am also trying to curb the problem.
Report
Re: New program Posted by Actor21 on 18 Jan 2013 at 9:16 PM
Sorry about that. As I said I didn't have time to test it. This should cure the infinite loop. The code handles Female the first time through the loop and Male the second time.
var
   .
   .
   .
   Marker : char ;
   Index  : integer ;
   GenStr : string[6] ;
   Count  : 1 .. 2 ;

begin
   .
   .
   .
   {
      Female and Male with highest value
   }
   for Count := 1 to 2 do begin  { loop two times }
      if Count = 1 then begin         { 'Female' the first time thru }
         Marker := 'F' ;
         GenStr := 'Female'
      end
      else begin                      { 'Male' the second time thru }
         Marker := 'M' ;
         GenStr := 'Male'
      end ;


      Index := 0 ;
      Max   := 0 ;
      for LoopCounter := 1 to NumberOfNames do begin
         if (ClassGen[LoopCounter] = Marker) and (ClassAvg[LoopCounter] > Max) then begin
            Max   := ClassAvg[LoopCounter] ;
            Index := LoopCounter
         end         
      end ;

      if Index = 0 then
         writeln ('There are no ', GenStr, 's in the class.')
      else
         writeln (ClassNames[Index], ' with an average of ',
                  ClassAvg[Index], ' is the highest ranking',       
                  Genstr, ' in the class.')
   end ;

Report
Re: New program Posted by Actor21 on 18 Jan 2013 at 9:25 PM
: hello there, am new at sortoff new into the pascal
: environment and would love to get some assistance in that please. i
: have to create a program that will allow the entry of 10 students’
: name, sex and grade which should display the percentage of students
: who got a grade of 50 or more.The Percentage of male students
: getting 50 or above together with the percentage of female students
: getting 50 or above.The program should also print the female with
: the highest average and the male with the highest average.
: please help me since this is puzzling me and in urgent need of
: submission. thanking the person who helps with this asap!!



Do you know how to use

* Procedures
* Functions
* Records
* User defined types, particularly enumerated types


Report
Re: New program Posted by vyirus on 19 Jan 2013 at 9:07 AM
hey, no i don't no much of them things especially in the Pascal environment. I was just given a crash course in it online and by some friends in order to get myself in it. so can you please give me some assistance in it since am beginning to love the programming sector and am thinking of getting into it full time because i love creating solutions. Thanks again Actor21, u have been a great help and i do appreciate all you have done for me.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.