Computer Science, asked by dhanesh21, 1 year ago

write a program to input principal rate and time and calculate simple interest

Answers

Answered by dikshaverma4you
14

Hello, my C++ program is as under for the required question. Hope it helps you.


#include<iostream.h>

#include<conio.h>

#include<process.h>

void main()

{

clrscr();

 float p,r,t,si;

 char ch;

 int choice;

 A:

 cout<<" Welcome to the coding world of Dhanesh \n";

 cout<<"Welcome to the Simple Interest Calculator by Dhanesh \n";

 cout<<"Enter the value of principal \n";

 cin>>p;

 cout<<"Enter the value of rate p.a. \n";

 cin>>r;

 cout<<"Enter the value of time period for which the amount is taken ( in years ) \n";

 cin>>t;

 cout<<"Do you want to calculate the simple interest for the above values entered ? (y/n) \n";

 cin>>ch;

 if(ch=='y')

 {

   si=(p*r*t)/100;

    cout<<"The Simple Interest (S.I.) calculate for the given values is = "<<si<<endl;

}

  if(ch=='n')

  {

    cout<<"Do you want to enter the new values ?  ( 1= yes; 0= no) ";

    cin>>choice;

      {

          if(choice==1)

          {

             goto A;

          }

          if(choice==0)

         {

           exit(0);

         }

       }      

    }

getch();

}  



Thank You  ^_^


BrainlyPromoter: great answer
BrainlyPromoter: can you tell me the use of "/n" ?
BrainlyPromoter: i mean "\n"
dikshaverma4you: Thank you, \n works the same as endl; i.e., to bring the next content in the next line.
Answered by BrainlyPromoter
14
Since, you have not mentioned the programming language, hence I am writing a Java program.

Begins as follows:
import java.util.Scanner;
public class SI
{
public static void calc()
{
Scanner brainly = new Scanner(System.in);
double p,r,t,ans;
System.out.println("Enter the principal, rate and time to calculate simple interest.");
p=brainly.nextDouble();
r=brainly.nextDouble();
t=brainly.nextDouble();
ans=(p*r*t)/100;
System.out.println("Simple Interest = "+ans);
}
}
Similar questions