/*******************************************************
Name: Coulumb's Fource and Gravitational Force
Copyright: BCS-1A
Author: Mohammad Hussnain Imtiaz
Date: 12/01/12 00:08
Description: USE OF DO WHILE AND SWITCH
********************************************************/
// PREPROCESSER DIRECTICE
#include<iostream>
#include<conio.h>
#include<cmath>
using namespace std ;
int main ()
{
// LOCAL DECLARATION
double q1=0.0,
q2=0.0,
cRadius=0.0,
F=0.0,
k=pow(9.0*10,9),
m1=0.0,
m2=0.0,
Fg=0.0,
G=pow(6.674*10,-11),
gRadius=0.0;
int choice=0;
char choice2 ;
cout << "Program to calculate Coulumb's Fource & Gravitational Force\n" ;
do
{
cout<< "\n\nPress 1 to calculate Coulumb's Force\n2 to calculate Gravitational Force ? " ;
cin >> choice;
switch (choice)
{
case 1:
cout << "Enter the value of q1 :" ;
cin >> q1;
cout << "Enter the value of q2 :" ;
cin >> q2;
cout << "Enter the Radius :" ;
cin >> cRadius;
F = (k * ( (q1*q2)/(pow(cRadius,2 ))));
cout << "The Coulumb's Force is :" << F ;
break ;
case 2:
cout << "Enter the value of m1 :" ;
cin >> m1;
cout << "Enter the value of m2 :" ;
cin >> m2;
cout << "Enter the Radius :" ;
cin >> gRadius;
Fg = (G * ( (m1*m2)/(pow(gRadius,2 ))));
cout << "The Gravitational Force is :" << Fg ;
break ;
default :
cout << "You enter invalid Selection." ;
} // end of switch statmant
cout << "\n\n\nFor the continution of program (y/n)? ";
cin >> choice2 ;
system("CLS");
}while (choice2 == 'Y' || choice2 == 'y');
system ("CLS");
cout << "\n\n\n\n\n\n\n\n\n "
<< " "
<< "Created By:Mohammad Hussnain Imtiaz" ;
getch();
return 0;
} // end of main function
No comments:
Post a Comment