ppt, rencana, diktat, how to solving dan problem solving

 

OPEN
link 

0 komentar:

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;

}

0 komentar:

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;

}
 

0 komentar:

Wikipedia

Hasil penelusuran