-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInvestment_asking_for_interest_and_money.txt
58 lines (46 loc) · 1.76 KB
/
Investment_asking_for_interest_and_money.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
54
55
56
57
58
Question 3c - investment calculator that needs to prompt the user the investment and the interest.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Investment_asking_for_interest_and_money
{
internal class Program
{
static int userAmount;
static int userInterest;
static int PERCENTAGE = 100;
static int YEARS_TOTAL = 1;
static int amount;
static void Main(string[] args)
{
//Declarations of variables
int userInterest;
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());
//Prompt user to enter interest
Console.WriteLine("\nPlease enter the interest:");
userInterest = Convert.ToInt32(Console.ReadLine());
//Call a method to calculate the investment total
totalAmount = CalculateInvestmentTotal(userAmount,userInterest);
//Display the amount of the investment
Console.WriteLine("\nThe investment for one year is:" + totalAmount);
}
static int CalculateInvestmentTotal(int userAmount, int userInterest)
{
//Declarations
int PERCENTAGE = 100;
int YEARS = 1;
int amount;
//Calculate the amount
amount = userAmount * YEARS * userInterest / PERCENTAGE;
return amount;
}
}
}