You will write a program in Motorola 68000 assembler that will calculate the use
ID: 643597 • Letter: Y
Question
You will write a program in Motorola 68000 assembler that will calculate the user's age in 2015 given the user's date of birth.
First, the program will print the programming assignment number, your name, and your class account, all on one line. Then your program will prompt the user to enter his/her birthdate in the format MM/DD/YYYY. Your program will then calculate the user's age in 2015, and print the string "* In 2015 you will be XX years old. *". The XX should be replaced by the person's age in 2015. The age field may be 1-3 characters wide. You may not add extra spaces to the string. It must be printed all on one line. Additionally, the answer must be preceded and followed by a line of * characters exactly the same length as the answer line. Thus, you will have a box surrounding the answer.
EI:
Explanation / Answer
using System; class AgeAfter10Years { static void Main() { int birthInt, birthMonthInt, birthYearInt, yearValueToInt, monthValueToInt, dayValueToInt; string birthdate, birthMonth, birthYear, yearValue, monthValue, dayValue; Console.WriteLine("Enter your birth date (numbers only allowed)"); birthdate = Console.ReadLine(); birthInt = Convert.ToInt32(birthdate); //value of borth date is converted to Int if (birthInt > 31 || birthInt < 1) //cheking for correctly entered date.month has 31 days at most { Console.WriteLine("Wrong birth date. You must be joking. Hahaha. No worries. Go on"); } Console.WriteLine("Enter your birth month(numbers only allowed)"); birthMonth = Console.ReadLine(); //birth month read from console birthMonthInt = Convert.ToInt32(birthMonth); //birth month converted to Int if (birthMonthInt > 12 || birthMonthInt < 1) //birth month check. yesr has 12 months at most { Console.WriteLine("Wrong birth month. You must be joking. Hahaha. No worries. Go on"); } Console.WriteLine("Enter your birth year(numbers only allowed)"); birthYear = Console.ReadLine(); //year read from console birthYearInt = Convert.ToInt32(birthYear); //year to Int if (birthYearInt < 1915 || birthYearInt > 2100) //check.assuming user is < 100years old and program will live 85 year at most { Console.WriteLine("Wrong birth year. You must be joking. Hahaha. No worries. Cannot calculate based on that joke"); } else if (birthYearInt > 2005 && birthYearInt < 2015) //condition for age between 1 and 10 { Console.WriteLine("quite impressive that you can code at that age.Pls try again"); } else { monthValue = DateTime.Now.ToString("MM"); //month read from console and converted to string dayValue = DateTime.Now.ToString("dd"); //day read from console and converted to string yearValue = DateTime.Now.ToString("yyyy"); //year read from console and converted to string monthValueToInt = Convert.ToInt32(monthValue); // month converted to Int dayValueToInt = Convert.ToInt32(dayValue); yearValueToInt = Convert.ToInt32(yearValue); if (monthValueToIntRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.