Microsoft Visual C++/cli step by Step



Download 2,23 Mb.
Pdf ko'rish
bet56/102
Sana31.12.2021
Hajmi2,23 Mb.
#228061
1   ...   52   53   54   55   56   57   58   59   ...   102
Bog'liq
Visual studio C step by step

 

CHAPTER 5

 

Decision and loop statements 



 61

Notice that because the date you typed was invalid, the application doesn’t display it. Instead, 

it just displays “The End.” You can make the application more user-friendly by displaying an 

error message if the date is invalid. To do so, you need to use a two-way test.



performing two-way tests

The following code shows how to define a two-way test for the Calendar Assistant application:

if (month >= 1 && month <= 12 && day >= 1 && day <= 31) 

    DisplayDate(year, month, day); 



else 


    Console::WriteLine("Invalid date"); 

Console::WriteLine("\nThe end\n");



The else body defines what action to perform if the test condition fails.

In this exercise, you will enhance your Calendar Assistant application to display an error message if 

an invalid date is entered.

1. 

Continue working with the project from the previous exercise.



2. 

Modify the main function, replacing the simple if with an if-else statement to test for valid or 

invalid dates.

if (month >= 1 && month <= 12 && day >= 1 && day <= 31) 

    DisplayDate(year, month, day); 



else 


    Console::WriteLine("Invalid date"); 

Console::WriteLine("\nThe end\n");





Download 2,23 Mb.

Do'stlaringiz bilan baham:
1   ...   52   53   54   55   56   57   58   59   ...   102




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish