Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Enter variable name in routine with vectors


  • Please log in to reply
3 replies to this topic

#1 marreco

marreco

    CC Newcomer

  • Member
  • PipPip
  • 13 posts
  • Programming Language:Delphi/Object Pascal

Posted 12 October 2012 - 02:04 PM

Hi.

In the previous year the difference is that I have to add the name

Write an algorithm using vectors, which receive and store the name and age of a number of people informed user, the end shows the sum and the average of all ages entered and where the user can verify the data entered many times as desired.

Program Aula11_Exc05;
Var
age:Array[1..1000] of Integer; 
sum, value, i:Integer;
media:Real;
pursue:String;
Begin
   Writeln('Enter the number of age who want to inform you: ');
  Readln(value);
   For i:= 1 To value Do
   Begin
	    Writeln('Enter the age...',i);
	    Readln(age[i]);
	    sum:= sum + age[i];
	    media:= sum/value;
   End;
   pursue:= 'yes';
   Writeln('The sum of the ages is: ',sum);
   Writeln('The media of the ages is: ',media:2:2);
   Readln;
	    While pursue = 'yes' Do
		 Begin
		  Writeln('What age want to check? ');
		  Readln(i);
		  Writeln('Age is:', age[i]);
		  Writeln('Want to make another query yes/no');
		  readln(pursue);
		 End;
End.

Thank you!!!
  • 0

#2 VNFox

VNFox

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 648 posts
  • Programming Language:C#, PHP
  • Learning:Assembly

Posted 12 October 2012 - 03:33 PM

ok ... so what do you need to change? I'm sorry, but the topic is kind of confuse.

So now all you have to do is to add "Enter your name" to the list / vector right ?
  • 0

www.pickmike.com
I don't just develop software. I find solutions to your business needs.


#3 marreco

marreco

    CC Newcomer

  • Member
  • PipPip
  • 13 posts
  • Programming Language:Delphi/Object Pascal

Posted 13 October 2012 - 04:40 PM

hi.

I had tried several ways before posting ...
I did as follows .....
Program Aula11_Exc05;
Var
age:Array[1..1000] of Integer;
name:Array[1..1000] of String;
sum, value, i:Integer;
media:Real;
pursue:String;
Begin
   Writeln('Enter the number of age who want to inform you: ');
  Readln(value);
   For i:= 1 To value Do
   Begin
	    Writeln('Enter the age...',i);
	    Readln(age[i]);
	    Writeln('Enter the name...',i);
	    Readln(name[i]);
	   
	    sum:= sum + age[i];
	    media:= sum/value;
   End;
   pursue:= 'yes';
   Writeln('The sum of the ages is: ',sum);
   Writeln('The media of the ages is: ',media:2:2);
   Readln;
	    While pursue = 'yes' Do
		 Begin
		  Writeln('What age want to check? ');
		  Readln(i);
		  Writeln('Age and name is:',name[i],' and she has ', age[i]);
		  Writeln('Want to make another query yes/no');
		  readln(pursue);
		 End;
End.

But finally I managed to solve!!

Thank you!
  • 0

#4 VNFox

VNFox

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 648 posts
  • Programming Language:C#, PHP
  • Learning:Assembly

Posted 13 October 2012 - 08:47 PM

Great ... you have finally solved your own issue. First step of thousands miles.
  • 0

www.pickmike.com
I don't just develop software. I find solutions to your business needs.





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download