PLease Help

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

Post Reply
toxicota
Newbie
Posts:1
Joined:Thu May 01, 2008 7:36 am
Location:San Diego, Ca
PLease Help

Post by toxicota » Thu May 01, 2008 7:46 am

Hi im so exited i had bearly started to mess arround with QBASik currently in my school they asked us to develop a program that reads information from a file
"NAME" "SSN" "WAGE"
"CHARLOTTE JONES","654928412",30520.9

and to print a list of this information and accumulate the combined wages, i was able to accomplish that however the teacher last night asked us to have the program add "-" character to format the SSN "000-00-0000" instead of printing it like "000000000" like it does now, next ill post the Code i have developed.

Thanks in advanced im Going NuTS trying to solve this.

Code: Select all

CLS
PRINT TAB(22); "Selected Employees (SSN > 599999999)"
PRINT
Chead$ = "Name            SSN                   WAGE"
Uline$ = "----            ---                   ----"
detline$ = "\ \ \ \##,###.##"
detlin$ = " \ \##,###.##"
tot! = 0
OPEN "H:\SWC\CIS101\prog\test.txt" FOR INPUT AS #1
PRINT TAB(13); Chead$;
PRINT TAB(13); Uline$;

DO
 INPUT #1, nam$, ssn$, wage!
 IF ssn$ > "599999999" THEN
 PRINT TAB(13); USING detline$; nam$; ssn$; wage!
 tot! = tot! + wage!
 END IF
LOOP UNTIL (EOF(1))

PRINT
PRINT USING detlin$; "Total Wages:"; tot!

buff1
Jr. Member
Posts:19
Joined:Mon Oct 30, 2006 4:37 pm
Contact:

Post by buff1 » Thu May 01, 2008 9:21 pm

Code: Select all

CLS
PRINT TAB(22); "Selected Employees (SSN > 599999999)"
PRINT
Chead$ = "Name              SSN           WAGE"
Uline$ = "----              ---           ----"
detline$ = "\               \ \           \ ##,###.##"
detlin$ = " \ \##,###.##"
tot! = 0
OPEN "test.txt" FOR INPUT AS #1 'H:\SWC\CIS101\prog\test.txt" FOR INPUT AS #1
PRINT TAB(13); Chead$;
PRINT TAB(13); Uline$;

DO
 INPUT #1, nam$, ssn$, wage!
  IF ssn$ > "599999999" THEN
   formattedssn$ = MID$(ssn$, 1, 3) + "-" + MID$(ssn$, 4, 2) + "-" + MID$(ssn$, 6)
   PRINT TAB(13); USING detline$; nam$; formattedssn$; wage!
    tot! = tot! + wage!
  END IF
LOOP UNTIL (EOF(1))
PRINT
PRINT TAB(13); USING detline$; "Total Wages:"; " "; tot!

Post Reply