193k views
1 vote
Design a program that asks the user to enter a month (in numeric form), a day, // and a year. The program should then call a function to determine // whether the month times the day equals the year. If the month times the day // equals the year then the function returns the boolean value true. If the month // times the day does not equal the year then the function returns the boolean value // false.

User YulePale
by
4.1k points

1 Answer

7 votes

//Written in C# this should work I did not know of any months and days that equal the year so I could not test that

using System;

class MainClass {

public static void Main (string[] args) {

Console.WriteLine ("Please Enter The Values Below as An Integer");

Console.Write("Month: ");

int month = Int32.Parse(Console.ReadLine());

Console.Write("Day: ");

int day = Int32.Parse(Console.ReadLine());

Console.Write("Year: ");

int year = Int32.Parse(Console.ReadLine());

Console.WriteLine(mdy(month, day, year));

}

static bool mdy(int m, int d, int y){

if(m * d == y){

return true;

}else{

return false;

}

}

}

User Ali Raza Bhayani
by
4.7k points