Recent

Author Topic: Please help me convert pseudocode to pascal  (Read 24962 times)

abdasalaf@yahoo.com

  • New member
  • *
  • Posts: 7
    • Predator Information Technology
Please help me convert pseudocode to pascal
« on: February 14, 2014, 05:06:53 am »
Please help me convert this psuedocode to pascal code , i dont know because im a beginner, pls help me.
If possible email it to : abdasalaf@yahoo.com
thanks in advance

Card, Sweet, Stationary, Toys = 0;
Input Code
For count =  1 to 280

X = Int(code/100)

case x of

0 : cards = cards + 1
1 : sweet = sweet + 1
2 : stationary = stationary + 1
3 : toys = toys + 1

otherwise error
end case

output card,sweet,stationary,toys

 

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
Re: Please help me convert pseudocode to pascal
« Reply #1 on: February 14, 2014, 09:01:20 am »
Tell me, what have you done in code. Your example is almost in pascalcode!
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

chain_reaction

  • New Member
  • *
  • Posts: 22
Re: Please help me convert pseudocode to pascal
« Reply #2 on: February 14, 2014, 09:20:11 am »

Card, Sweet, Stationary, Toys = 0;
Input Code
For count =  1 to 280

X = Int(code/100)

case x of

0 : cards = cards + 1
1 : sweet = sweet + 1
2 : stationary = stationary + 1
3 : toys = toys + 1

otherwise error
end case

output card,sweet,stationary,toys

Yes, you are showing a pascal dialect.

I help you with a little guide:

Card, Sweet, Stationary, Toys = 0; change with
Code: [Select]
var
  Card, Sweet, Stationary, Toys: Integer = 0;

For count =  1 to 280 change with
Code: [Select]
For count := 1 to 280 do

Input change with
Code: [Select]
Readln()

Symbol assignment = change with  :=
Code: [Select]
X := Int(code/100)

Output change with
Code: [Select]
Writeln()

otherwise error change with
Code: [Select]
  else
  begin
    // error
  end;

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Please help me convert pseudocode to pascal
« Reply #3 on: February 14, 2014, 10:06:25 am »
Quote
Card, Sweet, Stationary, Toys = 0; change with
Code: [Select]
var
  Card, Sweet, Stationary, Toys: Integer = 0;

No, you can't initialise variables "in bulk". You have to write
Code: [Select]
var
  Card: integer=0;
  Sweet: integer=0;
  Stationary: integer=0;
  Toys: Integer = 0;

abdasalaf@yahoo.com

  • New member
  • *
  • Posts: 7
    • Predator Information Technology
Re: Please help me convert pseudocode to pascal
« Reply #4 on: February 14, 2014, 10:53:42 am »
Can u write a pascal code for me pls??

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.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Please help me convert pseudocode to pascal
« Reply #5 on: February 14, 2014, 11:25:22 am »
This forum is not designed as a place where you get other people to do your homework for you.
If you write code in answer to such questions that gives errors you do not understand, and post your code, you are more likely to get helpful responses about what you might do to improve code that does not do what you want.

abdasalaf@yahoo.com

  • New member
  • *
  • Posts: 7
    • Predator Information Technology
Re: Please help me convert pseudocode to pascal
« Reply #6 on: February 14, 2014, 11:29:56 am »
This forum is not designed as a place where you get other people to do your homework for you.
If you write code in answer to such questions that gives errors you do not understand, and post your code, you are more likely to get helpful responses about what you might do to improve code that does not do what you want.

no i did the code but it is wrong  i tried a 100 times but not working what to do??

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12593
  • FPC developer.
Re: Please help me convert pseudocode to pascal
« Reply #7 on: February 14, 2014, 11:32:48 am »
no i did the code but it is wrong  i tried a 100 times but not working what to do??

Typically? Debug and/or write values and check they are correct, and thus pinpoint the problem spot.


abdasalaf@yahoo.com

  • New member
  • *
  • Posts: 7
    • Predator Information Technology
Re: Please help me convert pseudocode to pascal
« Reply #8 on: February 14, 2014, 11:37:22 am »
no i did the code but it is wrong  i tried a 100 times but not working what to do??

Typically? Debug and/or write values and check they are correct, and thus pinpoint the problem spot.

thank you but i want to compare your ones and mine to see??

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Please help me convert pseudocode to pascal
« Reply #9 on: February 14, 2014, 12:17:53 pm »
personally I do not understand the pseudocode at all, it makes no sense. what is the for loop suppose to do? what happens to all the values from 4 to 99 that might get produced by the statement
Code: [Select]
x := (code/100) assuming that int will do a truncate and not a round that will produce numbers from 0 to 99 depending on the value of Code.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Please help me convert pseudocode to pascal
« Reply #10 on: February 14, 2014, 04:18:45 pm »
Quote
no i did the code but it is wrong  i tried a 100 times but not working what to do??
Show us your wrong code.
Quote
thank you but i want to compare your ones and mine to see??
That's the way we do your homework. Most of us here are experienced with such a behavior. I myself have become lecturer assistant for 5.5 years (1 year longer than my whole college) and I've faced a lot of tricks to get homework done by someone else.

Dick, from the internet

  • Full Member
  • ***
  • Posts: 198
Re: Please help me convert pseudocode to pascal
« Reply #11 on: February 14, 2014, 07:08:56 pm »
Quote
thank you but i want to compare your ones and mine to see??
yeah, it never worked for me waaaay back when either.

"I don't want to copy your homework, I just want to see if you got the same answers that I did!"  :D

userx-bw

  • Full Member
  • ***
  • Posts: 178
Re: Please help me convert pseudocode to pascal
« Reply #12 on: February 14, 2014, 08:40:18 pm »
This forum is not designed as a place where you get other people to do your homework for you.
If you write code in answer to such questions that gives errors you do not understand, and post your code, you are more likely to get helpful responses about what you might do to improve code that does not do what you want.

no i did the code but it is wrong  i tried a 100 times but not working what to do??
do what

Quote
howardpc

 This forum is not designed as a place where you get other people to do your homework for you.
If you write code in answer to such questions that gives errors you do not understand, and post your code, you are more likely to get helpful responses about what you might do to improve code that does not do what you want.

said

show you real code so people can help you with it.


My Finished Projects
https://sourceforge.net/projects/mhsetroot/
https://sourceforge.net/projects/gmhsetrootfreepascalfrontend/

HP Elitetbook 6930p Dual Core Intel vPro 2.66 gHz
VOID (Linux) 64bit

Bart

  • Hero Member
  • *****
  • Posts: 5665
    • Bart en Mariska's Webstek
Re: Please help me convert pseudocode to pascal
« Reply #13 on: February 15, 2014, 01:55:25 pm »
Hee's the answer to all your homework.

Code: [Select]
Pogram DoMyHomwWork;

uses FreePascal, Lazarus, LazarusForum;

var
  Ans: String;
  LearnedAnythingUsefull: Boolean;
 
function OK(S: String): Boolean;
begin
  //Assume answer is wrong
  Result := False;
  If CopyPastedCodeActuallyWorksAndProducesRightResults(S) then Result := True;
  LearnedAnythingUsefull := False;
end;

function YesNo(B: Boolean): String;
const
  Res: Array[Boolean] of String = ('No','Yes');
begin
  Result := Res[B];
end;

begin
  repeat
    Ans := AskQuestionOnLazarusForum('Please do my homework');
  until OK(Ans);
  writeln('Did I learn anything usefull?', YesNo(LearnedAnythingUsefull));
end.

It needs fpc 3.8.7 in order to compile.

Bart

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12593
  • FPC developer.
Re: Please help me convert pseudocode to pascal
« Reply #14 on: February 15, 2014, 03:01:17 pm »
Typically? Debug and/or write values and check they are correct, and thus pinpoint the problem spot.
thank you but i want to compare your ones and mine to see??

If comparing with readily made other implementations was part of the assignment, I'm sure a reference version
would have been handed out to you.

I consider this thread now concluded. At least till you have specific questions with source code.

 

TinyPortal © 2005-2018