Write a program that prompts the user for different pieces of information, perfo
ID: 3670086 • Letter: W
Question
Write a program that prompts the user for different pieces of information, performs various calculations, and displays the requested results on the screen as indicated by each set of instructions.
Problem #1
Ask the user for the radius of a circle and calculate the area and circumference of the circle. Display the results on the screen. Make sure you program can handle both integer and decimal inputs.
Use the following formula(s) to assist you in your calculations: Area = pi * radius2
Circumference = 2 * pi * radius
Problem #2
Ask the user for the base and height of a right triangle and calculate the area and perimeter of the triangle. Display the results on the screen. sure your program can handle both integer and decimal inputs.
Use the following formula(s) to assist you in your calculations: Area = (1/2) * base * height
Opposite_Side2 + Adjacent_Side2 = Hypotenuse2 (for right triangles)
Problem #3
Ask the user for a principle amount, interest rate, compound frequency (per year), and number of years and determine the amount of money that would exist in an account given the compound interest accumulation for the provided parameters. Display the results on the screen and make sure you program can handle both integer and decimal inputs.
Use the following formula(s) to assist you in your calculations:
Amount_In_Account = Principle * (1 + (Rate / Annual_Compound_Frequency))^(Annual_Compound_Frequency * Years_Elapsed)
Remember to round your figures to something reasonable. For questions 1 and 2, use 3 points of precision after the decimal points. For problem #3, use the currency formatting features of Console.Write() and Cosole.WriteLine() to display the results. Make your program output attractive.
PLEASE DO ALL 3 PROBLEMS. THANK YOU
Explanation / Answer
Program #1
'VB program that prompts user to enter radisu of the cirlce and
'finds the area and circumefernce and print to console
Module Module1
Sub Main()
'Declare variables of type double
Dim radius As Double = 0
Dim area As Double = 0
Dim circumference As Double = 0
Console.WriteLine("Enter radius of Circle")
'read radius
radius = Convert.ToInt32(Console.ReadLine())
'Find area of the circle
area = Math.PI * radius * radius
'Find circumference of the circle
circumference = 2 * Math.PI * radius
'print radisu, area and circumference
Console.WriteLine("***Circle***")
'print output to 3 decimal places
Console.WriteLine("Radius :" & radius.ToString("N3"))
Console.WriteLine("Area : " & area.ToString("N3"))
Console.WriteLine("Circumfreence : " & circumference.ToString("N3"))
'pause the output on console unitl user press a key
Console.ReadKey()
End Sub
End Module
Sample Output:
Enter radius of Circle
10
***Circle***
Radius :10.000
Area : 314.159
Circumfreence : 62.832
------------------------------------------------------------------------------------
Program#2
'VB program that prompts base and height from user and finds the area
'and hypotenuse and print to console
Module Module2
Sub Main()
'Declare variables of type double
Dim base As Double = 0
Dim height As Double = 0
Dim area As Double = 0
Dim hypotenuse As Double = 0
Console.WriteLine("Enter base of Right angle triangle")
'read base
base = Convert.ToDouble(Console.ReadLine())
Console.WriteLine("Enter height of Right angle triangle")
'read height
height = Convert.ToDouble(Console.ReadLine())
'Find area of the triangle
area = (0.2) * base * height
'Find hypotenuse
hypotenuse = Math.Sqrt(Math.Pow(base, 2.0) + Math.Pow(height, 2.0))
'print area and hypotenuse
Console.WriteLine("***Right Angle Triangle***")
Console.WriteLine("Base : " & base.ToString("N3"))
Console.WriteLine("Height : " & height.ToString("N3"))
Console.WriteLine("Area of Right angle triangle :" & area.ToString("N3"))
Console.WriteLine("Hypotenuse : " & hypotenuse.ToString("N3"))
'pause the output on console unitl user press a key
Console.ReadKey()
End Sub
End Module
Sample output:
Enter base of Right angle triangle
3
Enter height of Right angle triangle
4
***Right Angle Triangle***
Base : 3.000
Height : 4.000
Area of Right angle triangle :2.400
Hypotenuse : 5.000
---------------------------------------------------------------------------------------------------------------------------------------
Program #3
Module Module3
Sub Main()
'Declare variables of type double
Dim Principle As Double = 0
Dim Rate As Double = 0
Dim Annual_Compound_Frequency As Double = 0
Dim Years_Elapsed As Double = 0
Dim Amount_In_Account As Double = 0
Console.WriteLine("Enter Principle amount")
'read principle
Principle = Convert.ToDouble(Console.ReadLine())
Console.WriteLine("Enter Rate")
'read rate
Rate = Convert.ToDouble(Console.ReadLine())
Console.WriteLine("Enter annual compound frequency")
'read rate
Annual_Compound_Frequency = Convert.ToDouble(Console.ReadLine())
Console.WriteLine("Enter Years")
'read years
Years_Elapsed = Convert.ToDouble(Console.ReadLine())
'Calculate compound intereset amount
Amount_In_Account = Principle * (1 + (Rate / Annual_Compound_Frequency)) ^ (Annual_Compound_Frequency * Years_Elapsed)
'print area and hypotenuse
Console.WriteLine("***Compound Interest Calculator***")
Console.WriteLine("Principle :" & Principle.ToString("N2"))
Console.WriteLine("Rate : " & Rate)
Console.WriteLine("Annual Compound Frequency : " & Annual_Compound_Frequency)
Console.WriteLine("Years : " & Years_Elapsed)
'Print amount in currency symbol
Console.WriteLine("Amount+Interest: " & Amount_In_Account.ToString("C2"))
'pause the output on console unitl user press a key
Console.ReadKey()
End Sub
End Module
Sample output:
Enter Principle amount
10000
Enter Rate
0.1
Enter annual compound frequency
20
Enter Years
5
***Compound Interest Calculator***
Principle :10,000.00
Rate : 0.1
Annual Compound Frequency : 20
Years : 5
Amount+Interest: $16,466.68
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.