Question
C# language Ask the user for a number and store it in an int. Ask the user for another number and store it in an
C# language
Ask the user for a number and store it in an int. Ask the user for another number and store it in an int as well. Add the two numbers together and store the result in an int. Output the result. Now, what happens when you try to add the numbers 1,000,000,000 and 2,000,000,000? Why?
Example Output
Please enter a number: 1000000000
Please enter a number: 1701
Gentle Jerry's Generic Goods only sells swords, shields, and potions. Write a program to display the prices of each, and ask the user for the amount they'd like to purchase. The number of swords and shields will use integers. But the potion is sold by the ounce and will use a floating-point variable type. Finally, display the individual costs of the selected items and the total cost of the purchase.
Example Output
Welcome to Gentle Jerry's Generic Goods!
Sword - 5 gold each
Shield - 8 gold each
Potion - 3 gold per ounce
How many Swords would you like? 2
How many Shields would you like? 1
How many ounces of Potion, sir? 20.5
2 Swords = 10 gold
1 Shields = 8 gold
20.5 Ounces of Potion = 61.5 gold
------------------------------
Total Cost = 79.5 gold
Write a program to swap the values of two variables. Ask the user for two separate inputs. Then devise an algorithm to put the value of the first variable into the second and the value of the second variable into the first, without losing any one of the two values. Hint: youll probably need to use another variable.
Ask the user for the current Pacific time and convert it to Eastern time (+3 hours). First, use an if statement to error check and verify that the number entered was between 1 and 12. Next, convert the users input to Eastern time. Finally, make sure to roll the time over if it exceeds 12 o'clock.
Example Output
Enter the hour to convert from Pacific to Eastern: 10
That would be 1 Eastern.
Enter the hour to convert from Pacific to Eastern: 16
That is not a valid time!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started