Write a program that reads three integers from the keyboard and outputs their su
ID: 3826776 • Letter: W
Question
Write a program that reads three integers from the keyboard and outputs their sum and product. Write a program that reads three double values from the keyboard and outputs their average. Write a program that asks you to type your name and hometown. Your program should then print your name and hometown to the console window. What is your name? Matt Where are you from? New Iberia, LA After pressing enter Your name is Matt and you are from New Iberia, LA! What is the output of the following program: int x = 10, y = 0; Console WriteLine("The first sum is {0}", (x++) - (y++)); Console e second sum is {0}", (--x) + (y--)); Create a program that asks the store this value to a variable x value from the user, the program will display the result of x + 100. So for example, if the user provides the number 6, the output will be 106. LAB Bonus Create a program that gets four integer values from the user. These values are stored to variables w, x, y, and z. If the sum of these integers is a multiple of 3, the program will display 0. If the sum of these numbers is not a multiple of 3, the program will display l. So for example, if the user provides values 1, 4, 6, and 3, the program will display "1", because 1 + 4 + 6 + 3 = 14, which is not a multiple of 3.Explanation / Answer
SOLUTION FOR 2.1
using System;
namespace Example application {
class Program{
public static void Main(string[] args){
Console.Write("Enter first number : ");
string input1 = Console.ReadLine();
Console.Write("Enter second number : ");
string input2 = Console.ReadLine();
Console.Write("Enter third number : ");
string input3 = Console.ReadLine();
int num1 = Convert.ToInt32(input1);
int num2 = Convert.ToInt32(input2);
int num3 = Convert.ToInt32(input3);
int sum = num1 + num2 + num3;
int prod = num1 * num2 * num3;
Console.WriteLine();
Console.WriteLine("The sum is",sum);
Console.WriteLine("The product is",prod);
}
}
}
SOLUTION FOR 2.2
using System;
namespace Example application {
class Program{
public static void Main(string[] args){
Console.Write("Enter first number : ");
string input1 = Console.ReadLine();
Console.Write("Enter second number : ");
string input2 = Console.ReadLine();
Console.Write("Enter third number : ");
string input3 = Console.ReadLine();
double num1 = double.Parse(input1);
double num2 = double.Parse(input2);
double num3 = double.Parse(input3);
double avg = (num1 + num2 + num3)/3;
Console.WriteLine();
Console.WriteLine("The average is",avg);
}
}
}
SOLUTION FOR 2.3
using System;
namespace Example application {
class Program{
public static void Main(string[] args){
Console.Write("What is your name? ");
string name = Console.ReadLine();
Console.Write("Where are you from?");
string place= Console.ReadLine();
Console.WriteLine();
Console.WriteLine(" Your name is ",name, "and you are from", place);
}
}
}
SOLUTION FOR LAB BONUS
using System;
namespace Example application {
class Program{
public static void Main(string[] args){
Console.Write("Enter first number : ");
string input1 = Console.ReadLine();
Console.Write("Enter second number : ");
string input2 = Console.ReadLine();
Console.Write("Enter third number : ");
string input3 = Console.ReadLine();
Console.Write("Enter fourth number : ");
string input4 = Console.ReadLine();
int num1 = Convert.ToInt32(input1);
int num2 = Convert.ToInt32(input2);
int num3 = Convert.ToInt32(input3);
int num4 = Convert.ToInt32(input4);
if ((num1+num2+num3+num4)%3==0)
{
Console.WriteLine("0");
}
else
{
Console.WriteLine("1");
}
}
}
}
using System;
namespace Example application {
class Program{
public static void Main(string[] args){
Console.Write("Enter first number : ");
string input1 = Console.ReadLine();
Console.Write("Enter second number : ");
string input2 = Console.ReadLine();
Console.Write("Enter third number : ");
string input3 = Console.ReadLine();
int num1 = Convert.ToInt32(input1);
int num2 = Convert.ToInt32(input2);
int num3 = Convert.ToInt32(input3);
int sum = num1 + num2 + num3;
int prod = num1 * num2 * num3;
Console.WriteLine();
Console.WriteLine("The sum is",sum);
Console.WriteLine("The product is",prod);
}
}
}
SOLUTION FOR 2.2
using System;
namespace Example application {
class Program{
public static void Main(string[] args){
Console.Write("Enter first number : ");
string input1 = Console.ReadLine();
Console.Write("Enter second number : ");
string input2 = Console.ReadLine();
Console.Write("Enter third number : ");
string input3 = Console.ReadLine();
double num1 = double.Parse(input1);
double num2 = double.Parse(input2);
double num3 = double.Parse(input3);
double avg = (num1 + num2 + num3)/3;
Console.WriteLine();
Console.WriteLine("The average is",avg);
}
}
}
SOLUTION FOR 2.3
using System;
namespace Example application {
class Program{
public static void Main(string[] args){
Console.Write("What is your name? ");
string name = Console.ReadLine();
Console.Write("Where are you from?");
string place= Console.ReadLine();
Console.WriteLine();
Console.WriteLine(" Your name is ",name, "and you are from", place);
}
}
}
SOLUTION FOR LAB BONUS
using System;
namespace Example application {
class Program{
public static void Main(string[] args){
Console.Write("Enter first number : ");
string input1 = Console.ReadLine();
Console.Write("Enter second number : ");
string input2 = Console.ReadLine();
Console.Write("Enter third number : ");
string input3 = Console.ReadLine();
Console.Write("Enter fourth number : ");
string input4 = Console.ReadLine();
int num1 = Convert.ToInt32(input1);
int num2 = Convert.ToInt32(input2);
int num3 = Convert.ToInt32(input3);
int num4 = Convert.ToInt32(input4);
if ((num1+num2+num3+num4)%3==0)
{
Console.WriteLine("0");
}
else
{
Console.WriteLine("1");
}
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.