Question: Questions are in the program: (c#) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MethodsPractice { class Program { static string momName
Questions are in the program: (c#)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace MethodsPractice { class Program {
static string momName = "MARGE"; static int momAge = 45; static string dadName = "HOMER"; static int dadAge = 47; static string oldestDaughterName = "LISA"; static int oldestDaughterAge = 9; static string sonName = "BART"; static int sonAge = 10; static string youngestDaughterName = "MAGGIE"; static int youngestDaughterAge = 1; static void Main(string[] args) { // Prompt the user for a name Console.WriteLine(" Please enter the first name of the person to find their age");
// read the name the user entered string firstName = Console.ReadLine();
// call the method to find the age int age = FindAgeByName(firstName);
// #1 // If the age not -1 then write the age // otherwise, write that the name wasn't found // #5 Call FindDadsAgeWhenBorn(name) // #6 Display the result of FindDadsAgeWhenBorn to the console.
Console.ReadLine(); // hold the output on screen until the user hits enter }
// Format of Methods // static returnDataType NameOfMethod(dataType parameter1, dataType paramter2) static int FindAgeByName(string name)
{ // #3 // WRITE THE IF STATEMENT TO FIND WHICH PERSON'S AGE TO RETURN // IF THE NAME DOESN'T MATCH ANY OF THE NAMES WE HAVE, THEN RETURN A -1
} // #4 // Create a method called FindDadsAgeWhenBorn which accepts the name of one of the children // return the age of the dad when the selected child was born. //
} }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
