Re: storing user input then using it in an expression ????
- Posted by Irv <mountains at MINDSPRING.COM> Jun 09, 1997
- 867 views
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)