OPEN
ppt, rencana, diktat, how to solving dan problem solving
ppt, rencana, diktat, how to solving dan problem solving
EXAMPLE 3.1( FIGURE 3.7 Square Root Program)
EXAMPLE 3.1( FIGURE 3.7 Square Root Program)
PROGRAM
#include <cmath>
#include <iostream>
using namespace std;
int main()
{
float first; //input: one of two data values
float second; //input: second of two data values
float answer; //output: a square root value
//get first number and display its square root.
cout << "Enter the first number: ";
cin >> first;
answer= sqrt(first);
cout << "The square root of the first number is "
<< answer << endl;
// Get second number and display its square root.
cout << "Enter the second number: ";
cin >> second;
answer= sqrt(second);
cout << "The square root of the second number is "
<< answer << endl;
// Display the square root of the sum of first and second.
answer= sqrt(first +second);
cout << "The square root of the sum of both numbers is "
<< answer << endl;
return 0;
}
#include <cmath>
#include <iostream>
using namespace std;
int main()
{
float first; //input: one of two data values
float second; //input: second of two data values
float answer; //output: a square root value
//get first number and display its square root.
cout << "Enter the first number: ";
cin >> first;
answer= sqrt(first);
cout << "The square root of the first number is "
<< answer << endl;
// Get second number and display its square root.
cout << "Enter the second number: ";
cin >> second;
answer= sqrt(second);
cout << "The square root of the second number is "
<< answer << endl;
// Display the square root of the sum of first and second.
answer= sqrt(first +second);
cout << "The square root of the sum of both numbers is "
<< answer << endl;
return 0;
}
FIGURE 3.5 Flat Washer Program
FIGURE 3.5 Flat Washer Program
DATA REQUIREMENTS
Problem Constant
PI 3.14159
Problem Inputs
double hole_diameter /* diameter of hole */
double edge_diameter /* diameter of outer edge */
double thickness /* thickness of washer */
double density /* density of material used */
double quantity /* number of washers made */
Problem Outputs
double weight /* weight of batch of washers */
Program Variables
double hole_radius /* radius of hole */
double edge_radius /* radius of outer edge */
double rim_area /* area of rim */
double unit_weight /* weight of 1 washer */
Relevant Formulas
area of a circle = * radius 2
radius of a circle = diameter / 2
rim area = area of outer circle − area of hole
unit weight = rim area * thickness * density
PROGRAM
#include <iostream>
using namespace std;
int main()
{
const float PI = 3.14159;
float holeDiameter; //input-diameter of hole
float edgeDiameter; //input-diameter of outer edge
float thickness; //input-diameter of washer
float density; //input-thickness of material used
float quantity; //input-density of washer made
float weight; //input-number of weight of washer batch
float holeRadius; //radius of hole
float edgeRadius; //radius of outer edge
float rimArea; //area of rim
float unitWeight; //weight of 1 washer
// Get the inner diameter, outer diameter, and thickness.
cout << "Inner diameter in centimeters: ";
cin >> holeDiameter;
cout << "Outer diameter in centimeters: ";
cin >> edgeDiameter;
cout << "Thickness in centimeters: ";
cin >> thickness;
// Get the material density and quantity manufactured.
cout << "Material density in grams per cubic centimeter: ";
cin >> density;
cout << "Quantity in batch: ";
cin >> quantity;
// Compute the rim area.
holeRadius = holeDiameter / 2.0;
edgeRadius = edgeDiameter / 2.0;
rimArea = PI*edgeRadius*edgeRadius -
PI*holeRadius*holeRadius;
// Compute the weight of a flat washer.
unitWeight = rimArea * thickness * density;
// Compute the weight of the batch of washers.
weight = unitWeight * quantity;
// Display the weight of the batch of washers.
cout<<"The expected weight of the batch is "<<weight<<"grams"<<endl;
return 0;
}
Problem Constant
PI 3.14159
Problem Inputs
double hole_diameter /* diameter of hole */
double edge_diameter /* diameter of outer edge */
double thickness /* thickness of washer */
double density /* density of material used */
double quantity /* number of washers made */
Problem Outputs
double weight /* weight of batch of washers */
Program Variables
double hole_radius /* radius of hole */
double edge_radius /* radius of outer edge */
double rim_area /* area of rim */
double unit_weight /* weight of 1 washer */
Relevant Formulas
area of a circle = * radius 2
radius of a circle = diameter / 2
rim area = area of outer circle − area of hole
unit weight = rim area * thickness * density
PROGRAM
#include <iostream>
using namespace std;
int main()
{
const float PI = 3.14159;
float holeDiameter; //input-diameter of hole
float edgeDiameter; //input-diameter of outer edge
float thickness; //input-diameter of washer
float density; //input-thickness of material used
float quantity; //input-density of washer made
float weight; //input-number of weight of washer batch
float holeRadius; //radius of hole
float edgeRadius; //radius of outer edge
float rimArea; //area of rim
float unitWeight; //weight of 1 washer
// Get the inner diameter, outer diameter, and thickness.
cout << "Inner diameter in centimeters: ";
cin >> holeDiameter;
cout << "Outer diameter in centimeters: ";
cin >> edgeDiameter;
cout << "Thickness in centimeters: ";
cin >> thickness;
// Get the material density and quantity manufactured.
cout << "Material density in grams per cubic centimeter: ";
cin >> density;
cout << "Quantity in batch: ";
cin >> quantity;
// Compute the rim area.
holeRadius = holeDiameter / 2.0;
edgeRadius = edgeDiameter / 2.0;
rimArea = PI*edgeRadius*edgeRadius -
PI*holeRadius*holeRadius;
// Compute the weight of a flat washer.
unitWeight = rimArea * thickness * density;
// Compute the weight of the batch of washers.
weight = unitWeight * quantity;
// Display the weight of the batch of washers.
cout<<"The expected weight of the batch is "<<weight<<"grams"<<endl;
return 0;
}
Langganan:
Postingan (Atom)
Wikipedia
Hasil penelusuran
=MY POST=
Popular Posts
-
1. Buatlah program yang menampilkan biodata pribadi anda. program #include <iostream> using namespace std; /* run this program using...
-
1. Buatlah analisis dan algoritma untuk mencari titik tengah sebuah garis yang ujung titiknya adalah A(x1,y1) dan B(x2,y2). PROGRAM #incl...
-
DOWNLOAD Di sini
-
#include<iostream> using namespace std; main() { int a,i,nilai_mhs[10]; float rerata,jumlah; cout<<" Menghitun...
-
A .Identifikasi masalah -Cara mengalikan vektor 2 elemen dan matriks 2x3 sekaligu vektor 3 elemen B .Menentukan in...
Diberdayakan oleh Blogger.
Text Widget
Text Widget
Contributors
Ads Inside Post
Featured Post
MENCARI VOLUME KUBUS #include <iostream> using namespace std; class kubus { int s; public: ...
Followers
Search Bar
Blog Archive
-
▼
2016
(68)
-
▼
April
(21)
- ppt, rencana, diktat, how to solving dan problem s...
- EXAMPLE 3.1( FIGURE 3.7 Square Root Program)
- FIGURE 3.5 Flat Washer Program
- FIGURE 3.2 Outline of Program Circle
- FIGURE 3.1 Edited Data Requirements and Algorithm ...
- KASUS 5.6
- KASUS 5.5
- BAB 6
- BAB 9
- KASUS 5.4
- KASUS 5.3
- form pendaftaran
- REFLEKSI MINGGU 6
- Bab 5
- BAB 7
- kasus 5.2
- BAB 3
- BAB 2
- BAB 1
- bab 4
- progra memecah secara manual nilai uang rupiah
-
▼
April
(21)
