Recent

Author Topic: 2 Pascal code help pls  (Read 5865 times)

abdasalaf@yahoo.com

  • New member
  • *
  • Posts: 7
    • Predator Information Technology
2 Pascal code help pls
« on: February 14, 2014, 11:02:06 am »
Can u write a pascal code for me pls for both question??

Question 1
 
A company is carrying out a survey by observing traffic at a road junction.
Each time a car, bus, lorry or other vehicle passed by the road junction it was noted down.
10000 vehicles were conducted during the survey.
WRITE A PASCAL CODE WHICH :
1. inputs all 10000 responses
2. outputs the number of cars, busses or lorries
3. outputs the number of vehicles that werent cars, buses or lorries during the survey
 
Question 2
Regis lives in brazil and often travels to USA, Europe and Japan.
He wants to be able to convert Brazilian Reais into US Dollars, European Euros or Japanese Yen.
THE CONVERSION FORMULAE IS:
 
currency value = number of reais*conversion rate
 
Write a pascal code which inputs the country he is visiting, exchange rate and amount in brazilian reais he is taking.
The output will be a value inn foreign currency or the name of the currency.

JanRoza

  • Hero Member
  • *****
  • Posts: 739
    • http://www.silentwings.nl
Re: 2 Pascal code help pls
« Reply #1 on: February 14, 2014, 11:57:34 am »
What have you written yourself so far? What problems did you encounter?
I think this is a school exercise, aren't they meant to be made by yourself?
OS: Windows 11 / Linux Mint 22.3
       Lazarus 4.6 RC FPC 3.2.2
       CodeTyphon 8.90 FPC 3.3.1

Bart

  • Hero Member
  • *****
  • Posts: 5702
    • Bart en Mariska's Webstek
Re: 2 Pascal code help pls
« Reply #2 on: February 14, 2014, 12:02:41 pm »
I think this is a school exercise, aren't they meant to be made by yourself?
+1

Bart

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: 2 Pascal code help pls
« Reply #3 on: February 14, 2014, 04:16:00 pm »
Double post, asking for homework without showing effort, bye!

abdasalaf@yahoo.com

  • New member
  • *
  • Posts: 7
    • Predator Information Technology
IVE TRIED AND CODE ATTACHED NOW HELP ME PLS!
« Reply #4 on: February 16, 2014, 06:15:58 am »
alright can u help me i tried the code

Question 1
 
A company is carrying out a survey by observing traffic at a road junction.
Each time a car, bus, lorry or other vehicle passed by the road junction it was noted down.
10000 vehicles were conducted during the survey.
WRITE A PASCAL CODE WHICH :
1. inputs all 10000 responses
2. outputs the number of cars, busses or lorries
3. outputs the number of vehicles that werent cars, buses or lorries during the survey
 
Question 2
Regis lives in brazil and often travels to USA, Europe and Japan.
He wants to be able to convert Brazilian Reais into US Dollars, European Euros or Japanese Yen.
THE CONVERSION FORMULAE IS:
 
currency value = number of reais*conversion rate
 
Write a pascal code which inputs the country he is visiting, exchange rate and amount in brazilian reais he is taking.
The output will be a value inn foreign currency or the name of the currency.

QUESTION 1 ANSWER

PSEUDOCODE

Cars,bus,lorry = 0;
input vehicle
for count = 1 to10000

case vehicle of
car:=car+1
bus:=bus+1
lorry:=lorry+1

otherwise vehicle+1
end case
next count
output car,bus,lorry,vehicle

PASCAL CODE FOR QUESTION 1

var
car:integer=0;
bus:integer=0;
lorry:integer=0;
vehicle:integer;

begin
for vehicle=1 to 10000 do
case vehicle of
car:=car+1
bus:=bus+1
lorry:=lorry+1

else
vehicle:=vehicle+1
end;
readln;
end.


QUESTION 2 Psuedocode

input number of reais,conversion rate,country

currency value = number of reais*conversion rate

if country = USA then
output currency = $

if country = europe then
output currency = euro

if country = japan then
output currency = yen

else error


BUT I DONT KNOW HOW TO WRTE THE PASCAL FOR QUESTION 2

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: IVE TRIED AND CODE ATTACHED NOW HELP ME PLS!
« Reply #5 on: February 16, 2014, 06:37:39 am »
Code: [Select]
PASCAL CODE FOR QUESTION 1

var
car:integer=0;
bus:integer=0;
lorry:integer=0;
vehicle:integer;

begin
for vehicle=1 to 10000 do [b]// syntax error, := should be used for initial for loop variable assignment[/b]
// I don't see you read anything here (to get input as required in the 1st step in the question)
case vehicle of
car:=car+1     // wrong case label usage
bus:=bus+1     // please see
lorry:=lorry+1 // http://wiki.lazarus.freepascal.org/Case

else
vehicle:=vehicle+1 // you use the same variable for for loop and counting other vehicles, this won't work, use different variables
end;
// no output? neither 2nd and 3rd steps are done
readln;
end.
Quote
BUT I DONT KNOW HOW TO WRTE THE PASCAL FOR QUESTION 2
Then I don't know how to help you..

 

TinyPortal © 2005-2018