-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInvestment_asking_for_amount.txt
53 lines (43 loc) · 1.55 KB
/
Investment_asking_for_amount.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Question 3b - Prompt the user to ask for the investment and calculate includingh displaying it
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Investment_asking_for_amount
{
internal class Program
{
static int userAmount;
static int INTEREST_PERCENTAGE = 2;
static int PERCENTAGE = 100;
static int YEARS_TOTAL = 1;
static int amount;
static void Main(string[] args)
{
//Declarations of variables
int userAmount;
int totalAmount;
//Open the program
Console.WriteLine("Welcome to the Investment Program:");
//Prompt user to enter the amount
Console.WriteLine("\nPlease enter the amount you are investing:");
userAmount = Convert.ToInt32(Console.ReadLine());
//Call a method to calculate the investment total
totalAmount = CalculateInvestmentTotal(userAmount);
//Display the amount of the investment
Console.WriteLine("\nThe investment for one year is:" + totalAmount);
}
static int CalculateInvestmentTotal(int userAmount)
{
//Declarations
int INTEREST = 2;
int PERCENTAGE = 100;
int YEARS = 1;
int amount;
//Calculate the amount
amount = userAmount * YEARS * INTEREST / PERCENTAGE;
return amount;
}
}
}