1. storing user input then using it in an expression ????

Can somone code this up for me so I can see how euphoria handles I/O.

Thank you, I'm a beginner.

/* Weekly pay report */
/* A program that calculates the pay of an employee */
Get employee data
INPUT "Please enter employee name: ", name$
INPUT "Enter job performed: ", job_performed$
INPUT "Enter number of hours worked: ", hrs_worked
INPUT "Enter employee code (valid codes are 'J' for journeymen, 'A' for
 apprentice, and 'C' for casual labor):", code$
Calculate pay
IF (code = = J)
     pay = hrs_worked * 12
ELSE
     IF (code == A)
          pay = hrs_worked * 10
     ELSE
          pay = hrs_worked * 8
     ENDIF
ENDIF
Output results
OUTPUT "Employee name: ", name$
OUTPUT "Job performed: ", job_performed$
OUTPUT "Hours worked: " , hrs_worked
OUTPUT "Wages: ", pay

new topic     » topic index » view message » categorize

2. Re: storing user input then using it in an expression ????

Terry McKenna wrote:
>
> Subject:      storing user input then using it in an expression ????
>
> Can somone code this up for me so I can see how euphoria handles I/O.
>
> Thank you, I'm a beginner.
>
OK, here's just one way. There are certainly others, probably someone will have
a better way, once this gets to the listserver,  but this does conform almost
line-for-line with your pseudocode:

-- Weekly pay report
-- A program that calculates the pay of an employee

include get.e

sequence name, job_performed, hrs_worked
atom hrs, pay
atom code

--Get employee data
puts(1, "Please enter employee name: ") name = gets(0)
puts(1, "\nEnter job performed: ")  job_performed = gets(0)
puts(1, "\nEnter number of hours worked: ") hrs_worked = gets(0)
puts(1, "\nEnter employee code\n (valid codes are "&
       "'J' for journeymen, 'A' for apprentice, and 'C' for casual labor):")
       code = getc(0)


--Calculate pay
hrs_worked = value(hrs_worked) -- convert from "string" to numeric
if hrs_worked[1] = GET_SUCCESS then
 hrs = hrs_worked[2] -- else will fail with hrs not assigned a value
end if

if code = 'J' then pay = hrs * 12
elsif code = 'A' then pay = hrs * 10
else pay = hrs * 8
end if

--Output results (using a couple of different print formatting methods)
puts(1, "\nEmployee name: "&name)
puts(1, "Job performed: "&job_performed)
printf(1, "Hours worked: %2.2f\n",hrs)
printf(1, "Wages: %4.2f" ,pay)

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu