Microsoft Visual C++/cli step by Step



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

 

CHAPTER 5

 

Decision and loop statements 



 59

4. 

Implement the GetMonth function as follows:

int GetMonth() 

    Console::Write("Month? "); 



    String ^input = Console::ReadLine(); 

    int month = Convert::ToInt32(input); 

    return month; 

}

This is a simplified implementation; later in this chapter, you will enhance the function to en-



sure that the user enters a valid month.

5. 

Implement the GetDay function as follows:

int GetDay(int year, int month) 

    Console::Write("Day? "); 



    String ^input = Console::ReadLine(); 

    int day = Convert::ToInt32(input); 

    return day; 

}

Later, you will enhance this function to ensure that the user enters a valid day for the given 



year and month.

6. 

Implement the DisplayDate function as shown in the following code to display the date as 

three numbers:

void DisplayDate(int year, int month, int day) 

    Console::WriteLine("\nThis is the date you entered:"); 



    Console::Write(year); 

    Console::Write("-"); 

    Console::Write(month); 

    Console::Write("-"); 

    Console::Write(day); 

    Console::WriteLine(); 

}

Later in this chapter you will enhance this function to display the date in a more user-friendly 



format.

7. 

Add the following code inside the main method, immediately before the return 0; Line:

Console::WriteLine("Welcome to your calendar assistant"); 

Console::WriteLine("\nPlease enter a date"); 

int year = GetYear(); 

int month = GetMonth(); 

int day = GetDay(year, month); 

 




Download 2,23 Mb.

Do'stlaringiz bilan baham:
1   ...   50   51   52   53   54   55   56   57   ...   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