Saturday, October 22, 2016

Qbasic Program: Calculate Profit or Loss



51. calculate profit

REM PROGRAM TO CALCULATE PROFIT
CLS
INPUT “ENTER COST PRICE”; CP
INPUT “ENTER SELLING PRICE”; SP
P = SP - CP
PRINT “PROFIT AMOUNT=”; P
END

USING SUB PROCEDURE

DECLARE SUB PROFIT (CP, SP)
CLS
INPUT “ENTER COST PRICE”; CP
INPUT “ENTER SELLING PRICE”; SP
CALL PROFIT(CP, SP)
END

SUB PROFIT(CP, SP)
P = SP - CP
PRINT “PROFIT AMOUNT=”; P
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION PROFIT (CP, SP)
CLS
INPUT “ENTER COST PRICE”; CP
INPUT “ENTER SELLING PRICE”; SP
PRINT “PROFIT AMOUNT=”; PROFIT(CP, SP)
END

FUNCTION PROFIT(CP, SP)
P = SP – CP
PROFIT = P
END FUNCTION








52. calculate loss

REM PROGRAM TO CALCULATE LOSS
CLS
INPUT “ENTER COST PRICE”; CP
INPUT “ENTER SELLING PRICE”; SP
L = CP - SP
PRINT “LOSS AMOUNT=”; L
END

USING SUB PROCEDURE

DECLARE SUB LOSS (CP, SP)
CLS
INPUT “ENTER COST PRICE”; CP
INPUT “ENTER SELLING PRICE”; SP
CALL LOSS(CP, SP)
END

SUB LOSS (CP, SP)
L = CP - SP
PRINT “LOSS AMOUNT=”; L
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION LOSS (CP, SP)
CLS
INPUT “ENTER COST PRICE”; CP
INPUT “ENTER SELLING PRICE”; SP
PRINT “LOSS AMOUNT=”; LOSS(CP, SP)
END

FUNCTION LOSS (CP, SP)
L = CP – SP
LOSS = P
END FUNCTION








53. calculate profit percentage

REM PROGRAM TO CALCULATE PROFIT PERCENTAGE
CLS
INPUT “ENTER COST PRICE”; CP
INPUT “ENTER SELLING PRICE”; SP
PP = ((SP – CP) / CP) * 100
PRINT “PROFIT PERCENTAGE=”; PP
END

USING SUB PROCEDURE

DECLARE SUB PROFITP (CP, SP)
CLS
INPUT “ENTER COST PRICE”; CP
INPUT “ENTER SELLING PRICE”; SP
CALL PROFITP(CP, SP)
END

SUB PROFITP (CP, SP)
PP = ((SP – CP) / CP) * 100
PRINT “PROFIT PERCENTAGE=”; PP
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION PROFITP (CP, SP)
CLS
INPUT “ENTER COST PRICE”; CP
INPUT “ENTER SELLING PRICE”; SP
PRINT “PROFIT PERCENTAGE=”; PROFITP(CP, SP)
END

FUNCTION PROFITP(CP, SP)
PP = ((SP – CP) / CP) * 100
PROFIT = PP
END FUNCTION







54. calculate loss percentage

REM PROGRAM TO CALCULATE LOSS PERCENTAGE
CLS
INPUT “ENTER COST PRICE”; CP
INPUT “ENTER SELLING PRICE”; SP
LP = ((CP – SP) / CP) * 100
PRINT “LOSS PERCENTAGE=”; LP
END

USING SUB PROCEDURE

DECLARE SUB LOSSP (CP, SP)
CLS
INPUT “ENTER COST PRICE”; CP
INPUT “ENTER SELLING PRICE”; SP
CALL LOSSP(CP, SP)
END

SUB LOSSP (CP, SP)
LP = ((CP – SP) / CP) * 100
PRINT “LOSS PERCENTAGE=”; LP
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION LOSSP (CP, SP)
CLS
INPUT “ENTER COST PRICE”; CP
INPUT “ENTER SELLING PRICE”; SP
PRINT “LOSS PERCENTAGE=”; LOSSP(CP, SP)
END

FUNCTION LOSSP (CP, SP)
LP = ((CP – SP) / CP) * 100
LOSS = LP
END FUNCTION






55. calculate selling price  where profit percentage and cost price is given

REM PROGRAM TO CALCULATE SELLING PRICE WHERE PROFIT PERCENTAGE AND COST PRICE IS GIVEN
CLS
INPUT “ENTER COST PRICE”; CP
INPUT “ENTER PROFIT PERCENTAGE”; PP
SP = CP * (100 + PP) / 100
PRINT “SELLING PRICE=”; SP
END

USING SUB PROCEDURE

DECLARE SUB SELLINGP (CP, PP)
CLS
INPUT “ENTER COST PRICE”; CP
INPUT “ENTER PROFIT PERCENTAGE”; PP
CALL SELLINGP(CP, PP)
END

SUB SELLINGP(CP, PP)
SP = CP * (100 + PP) / 100
PRINT “SELLING PRICE=”; SP
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION SELLINGP (CP, PP)
CLS
INPUT “ENTER COST PRICE”; CP
INPUT “ENTER PROFIT PERCENTAGE”; PP
PRINT “SELLING PRICE=”; SELLINGP(CP, PP)
END

FUNCTION SELLINGP(CP, PP)
SP = CP * (100 + PP) / 100
SELLINGP = SP
END FUNCTION





56. calculate selling price  where loss percentage and cost price is given

REM PROGRAM TO CALCULATE SELLING PRICE WHERE LOSS PERCENTAGE AND COST PRICE IS GIVEN
CLS
INPUT “ENTER COST PRICE”; CP
INPUT “ENTER LOSS PERCENTAGE”; LP
SP = CP * (100 - LP) / 100
PRINT “SELLING PRICE=”; SP
END

USING SUB PROCEDURE

DECLARE SUB SELLINGP (CP, LP)
CLS
INPUT “ENTER COST PRICE”; CP
INPUT “ENTER LOSS PERCENTAGE”; LP
CALL SELLINGP(CP, LP)
END

SUB SELLINGP(CP, LP)
SP = CP * (100 - LP) / 100
PRINT “SELLING PRICE=”; SP
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION SELLINGP (CP, LP)
CLS
INPUT “ENTER COST PRICE”; CP
INPUT “ENTER LOSS PERCENTAGE”; LP
PRINT “SELLING PRICE=”; SELLINGP(CP, LP)
END

FUNCTION SELLINGP(CP, LP)
SP = CP * (100 - LP) / 100
SELLINGP = SP
END FUNCTION




57. calculate cost price  where loss percentage and selling price is given

REM PROGRAM TO CALCULATE COST PRICE WHERE LOSS PERCENTAGE AND SELLING PRICE IS GIVEN
CLS
INPUT “ENTER SELLING PRICE”; SP
INPUT “ENTER LOSS PERCENTAGE”; LP
CP = (SP * 100) / (100 – LP)
PRINT “COST PRICE=”; CP
END

USING SUB PROCEDURE

DECLARE SUB COSTP (SP, LP)
CLS
INPUT “ENTER SELLING PRICE”; SP
INPUT “ENTER LOSS PERCENTAGE”; LP
CALL COSTP(SP, LP)
END

SUB COSTP(SP, LP)
CP = (SP * 100) / (100 – LP)
PRINT “COST PRICE=”; CP
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION COSTP (SP, LP)
CLS
INPUT “ENTER SELLING PRICE”; SP
INPUT “ENTER LOSS PERCENTAGE”; LP
PRINT “COST PRICE=”; COSTP(SP, LP)
END

FUNCTION COSTP(SP, LP)
CP = (SP * 100) / (100 – LP)
COSTP = CP
END FUNCTION




58. calculate cost price  where profit percentage and selling price is given
REM PROGRAM TO CALCULATE COST PRICE WHERE PROFIT PERCENTAGE AND SELLING PRICE IS GIVEN
CLS
INPUT “ENTER SELLING PRICE”; SP
INPUT “ENTER PROFIT PERCENTAGE”; PP
CP = (SP * 100) / (100 + PP)
PRINT “COST PRICE=”; CP
END

USING SUB PROCEDURE

DECLARE SUB COSTP (SP, PP)
CLS
INPUT “ENTER SELLING PRICE”; SP
INPUT “ENTER PROFIT PERCENTAGE”; PP
CALL COSTP(SP, LP)
END

SUB COSTP(SP, PP)
CP = (SP * 100) / (100 + PP)
PRINT “COST PRICE=”; CP
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION COSTP (SP, PP)
CLS
INPUT “ENTER SELLING PRICE”; SP
INPUT “ENTER PROFIT PERCENTAGE”; PP
PRINT “COST PRICE=”; COSTP(SP, PP)
END

FUNCTION COSTP(SP, PP)
CP = (SP * 100) / (100 + PP)
COSTP = CP
END FUNCTION



59. Input selling price and cost price calculate profit or loss percentage.
CLS
INPUT “ENTER COST PRICE&SELLING PRICE”; CP, SP
IF CP > SP THEN
LP = ((CP - SP)/CP) * 100
PRINT "LOSS PERCENTAGE="; LP
ELSEIF SP > CP THEN
PP = ((SP - CP)/CP) * 100
PRINT "PROFIT PERCENTAGE"; PP
ELSE
PRINT "NEITHER PROFIT NOR LOSS"
END IF : END
USING SUB PROCEDURE
DECLARE SUB PP(SP, CP)
CLS
INPUT “ENTER COST PRICE&SELLING PRICE”; CP, SP
CALL PP(SP, CP)
END
SUB PP (SP, CP)
IF CP > SP THEN
LP = ((CP - SP)/CP) * 100
PRINT "LOSS PERCENTAGE="; LP
ELSEIF SP > CP THEN
PP = ((SP - CP)/CP) * 100
PRINT "PROFIT PERCENTAGE"; PP
ELSE
PRINT "NEITHER PROFIT NOR LOSS"
END IF : END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION PP(SP, CP)
CLS
INPUT “ENTER COST PRICE”; CP
INPUT “ENTER SELLING PRICE”; SP
C = PP(SP, CP) : END
FUNCTION PP (SP, CP)
IF CP > SP THEN
LP = ((CP - SP)/CP) * 100
PRINT "LOSS PERCENTAGE="; LP
ELSEIF SP > CP THEN
PP = ((SP - CP)/CP) * 100
PRINT "PROFIT PERCENTAGE"; PP
ELSE
PRINT "NEITHER PROFIT NOR LOSS"
END IF : END FUNCTION

1 comment: