Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
www.student-center.alafadl.net
Imp/e :-
A company produces two types of TVs (Type 1 and Type 2), each type has
different sizes as shown in table below. Write a program to enter the TV type (
1 or 2 ), the TV size, and TV price before discount, then calculate its final price
after applying the discount and adding a transportation cost .. The user is not
allowed to enter wrong type
. M~duie M~iflH~~~ti11I~!!)?
... (::Y:t:</::::::~.,.
~tiiifl1i;fjl~:
~~~.Maon () A{? sf;~1Isinteger \ii
l,.•..•..•..
:'.:.:.:,·:·
..
•..
:·
:.::.·
..
::::.::::
•....
::
:•.::
:•.::
......
... .' :1: ,..:..:..:.:.:..:, .
.
'iV)6im price, newprice As single "'0
Case 2
If Size < 20 Then ..,.,.,.,.-
Newprice = 0.9*price + 20
Else
Newprice = 0.85*price + 30
End If
Case else
GotoX
End Select
Su b ~'!!:::(;::~',':lJ'jj>'
\:il,:~:t:;~itt;H;::~~:::e:;~:~~f.rice,,)(~II;!i~l,::::;:>
u' :i;e S~,!~!'jIJ,I,l!ib
= lnputbox (" Enter the
/:> -,
-,,
Newpriqf~:,>Q~:Amce + 20
Else
®
--- -=--
~wprice = 0.85*price + 30
End If
Else
Go to X
End Select
End sub
. End module
>:;'"
~'.',.
- ....)~" GoTo
Jmple :-
. Solution
........•..,--,- - .-'~ ;..,- :. -; -'~ .: ;; ~""---' ."" -. '-. .,' •.. ~"~'~ ,,'
--
1- Using Select Case Statement
Calcu'ate<tft~.,Il¢'f'·'Sa'aryof
"'i:~:~'::/
the work~i~/Jh~. pfpgta1iftn(iit;t~.att~rker
~::::::::::;::::::::::::::::::::;:;,
'!'::::::::::;:" )::::::::::::~~I "':'~::::::::~:;>.. -",,:::.::.,
na'n:g then pHrrt in a suitable form thgwatt(er nahil*h~6dAts.":S:at~f:y.
Write a program to enter the worker work hours and the hour price then
calculate the worker net salary. If the work hours exceeds 40 hours, the
extra hours will be as twice in price asthe normal hours.
Solution
Module Module!
Sub Main ()
:;:~~;~;~~~;ij;;>
E1(:::Hour.-&,;;:
Hour.s::~~O
s.,
'i(;t\M:;;;h
...
.ample :-
Percentage Grade
Percentage < 50 Fail
50 ~ Percentage < 65 Pass
65 s Percentage < 75 Good
75 s Percentage < 85 Very good
Percentage ~ 85 Excellent
Solution
'=:"
Oi*tradiif~~},j/
\fi~:T:~:~~}r~~
i(Iri*t 1
r;:::;::;:::::;:;;.-
\;:;;.;. \~}>"i~lJ~!!!I~!;.:.·
' •.. .
---·_:··:.:.l.;.: ..:: •.. :; •.:.:,: .....: ..:.:.::.: .....
Next
End if
. End Module
1- Repeat the last program using Select case
subjects.
..·.-":.·.1 •
-..•..
..~.. -
',"
.I~~"J
.:::::::::::~:-.
/;::::~;::::::'P'
®
.ample :-
~~~'3~1
cp _____________
f~'
I
Solution
. Mocfule-Modulel
\". RZ =;~,~~~~r~:.
Enterthe s~cond:esis~,~~,~~;i;j
i:?::<~J;==1,mw.tbo~J Enter the Third reslstance:::::):}:::-:::-
12=0
13=0 <;~:?t~::::"
11 = V I Rt
12= 11 * R3 t:t~~,:~:~~J\
13= 11-12 '<':;;:::ff:i):i~~~[~~~~f~[[)
End If
Msgbox (" The Three Currents are" & 11& 12 & 13)
~ End Sub
~ End Module
~
N I
I
-I
~
-e
f'+
o
_.
I/)
3
-
s::
QJ
f'+
Ci)
-I
'::T
Ci)
.1/)
ro
Q
~
n
C
f'+
I/)
.' 1m pie :-
Solution
- Module Modulel
Sub Main ()
\)]]):»:.J::" ..
End If
Next
. End Sub
@
. ' . 'Jmple :-
Solution
-. ~ , ..-.-
Module Module!
Sub Main 0
Dim Numl, Num2 as Integer
Dim Op as String
Case" /"
End Select
.'. "" .; ••.••••• " ,~, ', •.•••••• , ••.• ~ .••. - 'co '. ", ~_'. . •••. _, ., "" "" '.'~ .~,. ~¥.' •• _
1- Using IF Statement
2- He can determined the operators as follow
( * , mod, / , \ , + , 1\ )
· -' ample :-
Solution
Module Modulel
Sub Main ()
Dim I, n, fact As Integer
X: ~';"
N = Inp.~,tbox
::·;:;:1
( " Ent~Hh:gv.qlue
:;::::.:::::::::::::::;~.{'
of integer number" ) \a!i~~~~>:',J:~':_
If n <i&Then 'fri':>':'
.' Jmple:-
Solution
~.Module Modu~Jel
Sub Main 0
Dim a, b, c, d, Xl, X2 As Single
a= Inputbox ( " enter the value of coefficient a ")
b= Inputbox ( " enter the value of coefficient b ")
c= Inputbox ( " enter the value of coefficient c " )
d=bI\2-4*a*c ~':-.
if d 1~Then ~);-':lt>
Msg~px ( " imaginal!y:r.oots " )
\l;j~f~~~>:',J:~':.
I,
100
100