Create a project named Program_2_Basic_Arithmetic. Use the material in Chapter 2
ID: 3861994 • Letter: C
Question
Create a project named Program_2_Basic_Arithmetic. Use the material in Chapter 2 to create a program that, in a single main function: Prompts the user to enter a first name, middle initial, and last name. Accept all three arguments using a single statement. Print the entire name, with a period after the middle initial. Display the integer value of the character represented in the middle initial. Prompts the user to enter three numbers; with them, perform the following operations: Find the average of all three numbers using integral math only. Find the average of all three numbers using floating-point math. Find the average of the first two numbers, then find the remainder when dividing the third number by the result. in this order: add the first two numbers, subtract the second two numbers, and multiply the results together. Prompts the user to enter a dollar amount; with it, perform the following operations: With the whole dollar count, display the amount using the fewest units of currency in denominations of $100, $50, $20. $10, $5, $2, and $1. With the change, display the amount using the fewest units of currency in quarters, dimes, nickels, and pennies. Use constants where appropriate. the rubric for this assignment follows: Program fulfills all tasks listed in assignment description: 70% Program is organized in a logical fashion (uses functions, etc.): 15% Program conforms to style guidelines {meaningful identifiers, comments, etc.): 15% No credit will be received for assignments not placed in the appropriate share drive folder with the designated file/folder name. (Inputs will be shaded. Bold outputs must change depending on the input.) Enter your first name, middle initial, and last name (separated by spaces). Mike A Brown Brown, Mike A.Explanation / Answer
Per the guidelines giving all parts solution to #1 and #2
//#1
Console.WriteLine("Enter your firstname, middle initial and last name (separated by spaces): ");
string line = Console.ReadLine();
string[] names = line.Split(' ');
Console.WriteLine(names[2] + ", " + names[0] + " " + names[1] + ".");
//#2
Console.WriteLine("Enter 3 numbers (separated by spaces): ");
line = Console.ReadLine();
string[] numbers = line.Split(' ');
int average = (Convert.ToInt16(numbers[0]) + Convert.ToInt16(numbers[1]) + Convert.ToInt16(numbers[2])) / 3;
double dAverage = Convert.ToDouble( (Convert.ToInt16(numbers[0]) + Convert.ToInt16(numbers[1]) + Convert.ToInt16(numbers[2])) / Convert.ToDouble(3.0));
double dAveragetwoNumbers = Convert.ToDouble((Convert.ToInt16(numbers[0]) + Convert.ToInt16(numbers[1])) / Convert.ToDouble(2.0));
double remainder = Convert.ToInt16(numbers[2]) % dAveragetwoNumbers;
double exp = ((Convert.ToInt16(numbers[0]) + Convert.ToInt16(numbers[1])) * (Convert.ToInt16(numbers[0]) - Convert.ToInt16(numbers[1])));
Console.WriteLine("Integer Average: " + average);
Console.WriteLine("Floating Average: " + System.Math.Round(dAverage, 2));
Console.WriteLine("Reminder: Average 2 numbers and divide by 3rd: " + System.Math.Round(remainder, 2));
Console.WriteLine("Exp" + System.Math.Round(exp, 2));
Console.ReadLine();
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.