- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Golang Program to Compute Simple Interest Given all the Required Values
Steps
- Read the values for principal amount, rate and time.
- Using the formula, compute the simple interest.
- Print the value for the computed interest.
Enter the principal amount: 200 Enter the time(years): 5 Enter the rate: 5 The simple interest is: 50 | Enter the principal amount: 70000 Enter the time(years): 1 Enter the rate: 4 The simple interest is: 2800 |
Explanation
- User must enter the values for the principal amount, rate and time.
- The formula: (amount*time*rate)/100 is used to compute the simple interest.
- The simple interest is later printed.
Example
package main import "fmt" func main() { var principal, time, rate int fmt.Print("Enter the principal amount: ") fmt.Scanf("%d", &principal) fmt.Print("Enter the time in years: ") fmt.Scanf("%d", &time) fmt.Print("Enter the rate: ") fmt.Scanf("%d", &rate) simpleInterest :=(principal*time*rate)/100 fmt.Println("The simple interest is: ", simpleInterest) }
Output
Enter the principal amount: 10000 Enter the time in years: 5 Enter the rate: 5 The simple interest is: 2500
Advertisements