5.11 Figure 5.23 Program to Draw a Moving Ball
Senin, 31 Maret 2014
Minggu, 30 Maret 2014
Kamis, 27 Maret 2014
Chapter 3 Ebooks HOW SOLVE IT BY COMPUTER 3.8
Computing The Nth Fibonanci Number
Algoritma :
1. Deklarasi
input : Banyaknya baris Fibonanci
output : Jumlah deret Fibonanci
2. Deskripsi
int i , c, masuk , a, b , jumlah;
Flowchart :
c++:
Algoritma :
1. Deklarasi
input : Banyaknya baris Fibonanci
output : Jumlah deret Fibonanci
2. Deskripsi
int i , c, masuk , a, b , jumlah;
Flowchart :
c++:
Categories
Tugas Ebooks How To Solve It By Computer
Chapter 3 Ebooks HOW SOLVE IT BY COMPUTER 3.7
Raising a Number to a Large Power
1. Analisis
Menghitung Bilangan Berpangkat sampai N
2. Identifikasi
Input : Bilangan dan btasan pangkat
Output : hasi Perpangkatan
3. Algoritma
a. Deklarasi
a,b,c,hasil (integer)
b. Deskripsi
while (1)
if(b<=0)
c=1
while (!(c>b))
c = c + 1
Flowchart :
c++ :
1. Analisis
Menghitung Bilangan Berpangkat sampai N
2. Identifikasi
Input : Bilangan dan btasan pangkat
Output : hasi Perpangkatan
3. Algoritma
a. Deklarasi
a,b,c,hasil (integer)
b. Deskripsi
while (1)
if(b<=0)
c=1
while (!(c>b))
c = c + 1
Flowchart :
c++ :
Categories
Tugas Ebooks How To Solve It By Computer
Latihan Individu SAP Pertemuan 3
Menentukan Nilai akhir
1. Analisis :
Menentukan Nilai Akhir
2. Identifikasi :
input : Nilai Pertama , nilai Kedua , nilai Ketiga
Output : Nilai akhir
Flowchart :
1. Analisis :
Menentukan Nilai Akhir
2. Identifikasi :
input : Nilai Pertama , nilai Kedua , nilai Ketiga
Output : Nilai akhir
Flowchart :
Categories
Tugas SAP
Latihan Individu SAP Pertemuan 3
Menentukan Persamaan Kuadrat
Algoritma :
Input : a,b,c
Output : Persamaan Kuadrat
a,b,c,x1,x2,D (Float)
Flowchart :
c++ :
Algoritma :
Input : a,b,c
Output : Persamaan Kuadrat
a,b,c,x1,x2,D (Float)
Flowchart :
c++ :
Categories
Tugas SAP
Latihan Individu SAP Pertemuan 3
Menetukan Bilangan Genap dan Ganjil
Algoritma :
1. Deklarasi
bilangan , sisa (integer)
keterangan (string)
2. Deskripsi
inputkan bilangan;
keterangan = " Bilangan Genap ";
sisa = bilangan % 2;
if ( sisa = 1)
keterangan = " Bilangan Ganjil "
Flowchart :
c++ :
Algoritma :
1. Deklarasi
bilangan , sisa (integer)
keterangan (string)
2. Deskripsi
inputkan bilangan;
keterangan = " Bilangan Genap ";
sisa = bilangan % 2;
if ( sisa = 1)
keterangan = " Bilangan Ganjil "
Flowchart :
c++ :
Categories
Tugas SAP
Selasa, 25 Maret 2014
Latihan Individu SAP Pertemuan 4
Membuat Tabel Perkalian
1. Analisis :
Membuat tabel Perkalian
2. Identifikasi
Output : Tabel Perkalian
c++ :
1. Analisis :
Membuat tabel Perkalian
2. Identifikasi
Output : Tabel Perkalian
c++ :
Categories
Tugas SAP
Latihan Individu SAP Pertemuan 4
1. Analisis :
Membuat Diamond dengan perulangan
2. Identifikasi
Input : nilai n
output : diamond
3. Algoritma :
Deklarasi
int i, n, odd{50};
const char spasi = 177;
const char diamond = ' * ';
c++ :
Membuat Diamond dengan perulangan
2. Identifikasi
Input : nilai n
output : diamond
3. Algoritma :
Deklarasi
int i, n, odd{50};
const char spasi = 177;
const char diamond = ' * ';
c++ :
Categories
Tugas SAP
Ebooks Chapter 5 PROBLEM SOLVING AND PROGRAM DESIGN IN C
5.6 Figure 5.10 Sentinel-controlled while Loop
#include <cstdlib>
#include <iostream>
#define sentinel -99
using namespace std;
int main(int argc, char *argv[])
{
int sum=0,score;
cout<<"Enter First Score(or "<<sentinel<<" to quit> ";
cin>>score;
while(score != sentinel) {
sum += score;
cout<<"Enter Next score ("<<sentinel<<"to quit)> ";
cin>>score;
}
cout<<"Sum of Exam scores is "<<sum<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
#include <cstdlib>
#include <iostream>
#define sentinel -99
using namespace std;
int main(int argc, char *argv[])
{
int sum=0,score;
cout<<"Enter First Score(or "<<sentinel<<" to quit> ";
cin>>score;
while(score != sentinel) {
sum += score;
cout<<"Enter Next score ("<<sentinel<<"to quit)> ";
cin>>score;
}
cout<<"Sum of Exam scores is "<<sum<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
c++ :
Ebooks Chapter 5 PROBLEM SOLVING AND PROGRAM DESIGN IN C
5.5 Figure 5.9 Program To Monitor Gasoline Storage Tank
#include <cstdlib>
#include <iostream>
#define capacity 80000.0
#define min_pct 10
#define gals_per_brl 42.0
double monitor_gas(double min_supplay,double start_supply);
using namespace std;
int main(void)
{
double start_supply, min_supply, current;
min_supply = min_pct/100.0*capacity;
cout<<"Numbers Of Barrels currently in tank : ";
cin>>start_supply;
current = monitor_gas(min_supply, start_supply);
cout<<"Only Barrels are left."<<current<<endl<<endl;
cout<<"*** WARNING ***"<<endl;
cout<<"Available Supply is lesss than percent of"<<min_pct<<"tank's "<<endl;
cout<<capacity<<"barrel capacity."<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
double monitor_gas(double min_supply,double start_supply)
{
double remov_gals, remov_brls,current;
for(current = start_supply; current >= min_supply; current -= remov_brls){
cout<<"Barrels are available."<<current<<endl<<endl;
cout<<"Enter number of gallons removed : ";
cin>>remov_gals;
remov_brls = remov_gals/gals_per_brl;
cout<<"After removal of"<<remov_gals<<"gallone ("<<remov_brls<<"barrels)"<<endl;
}
return(current);
}
#include <cstdlib>
#include <iostream>
#define capacity 80000.0
#define min_pct 10
#define gals_per_brl 42.0
double monitor_gas(double min_supplay,double start_supply);
using namespace std;
int main(void)
{
double start_supply, min_supply, current;
min_supply = min_pct/100.0*capacity;
cout<<"Numbers Of Barrels currently in tank : ";
cin>>start_supply;
current = monitor_gas(min_supply, start_supply);
cout<<"Only Barrels are left."<<current<<endl<<endl;
cout<<"*** WARNING ***"<<endl;
cout<<"Available Supply is lesss than percent of"<<min_pct<<"tank's "<<endl;
cout<<capacity<<"barrel capacity."<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
double monitor_gas(double min_supply,double start_supply)
{
double remov_gals, remov_brls,current;
for(current = start_supply; current >= min_supply; current -= remov_brls){
cout<<"Barrels are available."<<current<<endl<<endl;
cout<<"Enter number of gallons removed : ";
cin>>remov_gals;
remov_brls = remov_gals/gals_per_brl;
cout<<"After removal of"<<remov_gals<<"gallone ("<<remov_brls<<"barrels)"<<endl;
}
return(current);
}
c++ :
Ebooks Chapter 5 PROBLEM SOLVING AND PROGRAM DESIGN IN C
5.4 Figure 5.8 Displaying a Celcius to Farenheit Conversion Table
#include <cstdlib>
#include <iostream>
#define cbegin 10
#define climit -5
#define cstep 5
using namespace std;
int main(int argc, char *argv[])
{
int celcius;
double Farenheit;
cout<<"Celcius \t farenheit"<<endl<<endl;
for(celcius=cbegin;celcius>=climit;celcius -= cstep) {
Farenheit= 1.8*celcius+32.0;
cout<<"Celcius : "<<celcius<<"\t farenheit "<<Farenheit<<endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
#include <cstdlib>
#include <iostream>
#define cbegin 10
#define climit -5
#define cstep 5
using namespace std;
int main(int argc, char *argv[])
{
int celcius;
double Farenheit;
cout<<"Celcius \t farenheit"<<endl<<endl;
for(celcius=cbegin;celcius>=climit;celcius -= cstep) {
Farenheit= 1.8*celcius+32.0;
cout<<"Celcius : "<<celcius<<"\t farenheit "<<Farenheit<<endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
c++ :
Ebooks Chapter 5 PROBLEM SOLVING AND DESIGN PROGRAM IN C
5.4 Figure 5.7 Function to Compute Factorial
#include <cstdlib>
#include <iostream>
using namespace std;
int faktorial (int n){
int i, product=1;
for (i=n; i>1; --i){
product=product*i;
}
return product;
}
int main(int argc, char *argv[])
{
int n;
cout<<"Inputkan Nilai : ";
cin>>n;
cout<<"Faktorial : " <<faktorial(n)<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
#include <cstdlib>
#include <iostream>
using namespace std;
int faktorial (int n){
int i, product=1;
for (i=n; i>1; --i){
product=product*i;
}
return product;
}
int main(int argc, char *argv[])
{
int n;
cout<<"Inputkan Nilai : ";
cin>>n;
cout<<"Faktorial : " <<faktorial(n)<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
c++ :
Ebooks Chapter 5 PROBLEM SOLVING AND PROGRAM DESIGN IN C
5.4 Figure 5.5 Using a for Statement in a Counting Loop
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int count_emp, number_emp;
float rate,pay,total_pay=0.0,hours;
cout<<"Enter Number Og Employees> ";
cin>>number_emp;
for(count_emp=0;count_emp < number_emp; count_emp+=1){
cout<<"hours> ";
cin>>hours;
cout<<"Rate> $ ";
cin>>rate;
pay= hours*rate;
cout<<"pay is= $ "<<pay<<endl;
total_pay=total_pay+pay;
}
cout<<"All Employes processed"<<endl;
cout<<"Total Payroll is "<<total_pay<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int count_emp, number_emp;
float rate,pay,total_pay=0.0,hours;
cout<<"Enter Number Og Employees> ";
cin>>number_emp;
for(count_emp=0;count_emp < number_emp; count_emp+=1){
cout<<"hours> ";
cin>>hours;
cout<<"Rate> $ ";
cin>>rate;
pay= hours*rate;
cout<<"pay is= $ "<<pay<<endl;
total_pay=total_pay+pay;
}
cout<<"All Employes processed"<<endl;
cout<<"Total Payroll is "<<total_pay<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
c++ :
Ebooks Chapter 5 PROBLEM SOLVING AND PROGRAM DEIGN IN C
5.3 Figure 5.4 Program To Compute Company Payroll
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int count_emp=0, number_emp;
double rate,pay,total_pay=0,hours;
cout<<"Enter Number Of employees : ";
cin>>number_emp;
while(count_emp<number_emp){
cout<<"Karyawan "<<count_emp+1<<endl;
cout<<"hours> ";
cin>>hours;
cout<<"Rate> ";
cin>>rate;
pay=hours*rate;
cout<<"Pay is = $ "<<pay<<endl;
total_pay=total_pay+pay;
count_emp=count_emp+1;
}
cout<<"All Employees Processed"<<endl;
cout<<"Total payroll is " <<total_pay<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int count_emp=0, number_emp;
double rate,pay,total_pay=0,hours;
cout<<"Enter Number Of employees : ";
cin>>number_emp;
while(count_emp<number_emp){
cout<<"Karyawan "<<count_emp+1<<endl;
cout<<"hours> ";
cin>>hours;
cout<<"Rate> ";
cin>>rate;
pay=hours*rate;
cout<<"Pay is = $ "<<pay<<endl;
total_pay=total_pay+pay;
count_emp=count_emp+1;
}
cout<<"All Employees Processed"<<endl;
cout<<"Total payroll is " <<total_pay<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
C++ :
Latihan Kelompok PPT Pertemuan 4
Simulasi Pembelian Bahan Bakar
1. Deklarasi :
Liter : Integer
Uang : Integer
2. Deskripsi :
Read (liter);
Options Liter
1. 1 liter 6500
2. 2 liter 13000
3. 3 liter 19500
End (select)
write (L)
C++:
class Fuel {
Public :
void input();
void process ();
void output ();
Private :
int output;
int liter;
};
void Fuel :: input (){
cout<<"Enter The Price of Fuel : " ;
cin>>output;
cout<<"type of fuel : "; cin>>output;
}
void Fuel :: process(){
output = liter * money
}
void Fuel :: output (){
cout<<"The Output Of The Process : "<<result;
}
int main(int argc, char * argv []) {
Fuel X;
X input ();
X process ();
X output ();
System ("pause");
Return exit_succes;
}/* Import to jeliot : */
{Public class fuel
void static void input ();
void static void process();
void static void output ();
private int output;
private int liter;
};
Public void input();{
system.out.print ("Enter the Price of fuel")
output=input.readint();
system.out.print("type of fuel");
output=input.readint();
}
Public void process(){
output=liter * money
}
Public void output(){
syetem.out.print("output of the process : " + result);
}
Public static void main(){
X = new fuel ();
X.input();
X.process();
X.output();
}}
1. Deklarasi :
Liter : Integer
Uang : Integer
2. Deskripsi :
Read (liter);
Options Liter
1. 1 liter 6500
2. 2 liter 13000
3. 3 liter 19500
End (select)
write (L)
C++:
class Fuel {
Public :
void input();
void process ();
void output ();
Private :
int output;
int liter;
};
void Fuel :: input (){
cout<<"Enter The Price of Fuel : " ;
cin>>output;
cout<<"type of fuel : "; cin>>output;
}
void Fuel :: process(){
output = liter * money
}
void Fuel :: output (){
cout<<"The Output Of The Process : "<<result;
}
int main(int argc, char * argv []) {
Fuel X;
X input ();
X process ();
X output ();
System ("pause");
Return exit_succes;
}/* Import to jeliot : */
{Public class fuel
void static void input ();
void static void process();
void static void output ();
private int output;
private int liter;
};
Public void input();{
system.out.print ("Enter the Price of fuel")
output=input.readint();
system.out.print("type of fuel");
output=input.readint();
}
Public void process(){
output=liter * money
}
Public void output(){
syetem.out.print("output of the process : " + result);
}
Public static void main(){
X = new fuel ();
X.input();
X.process();
X.output();
}}
Categories
Tugas PPT
Latihan Individu PPT Pertemuan 4
Bilangan Habis Dibagi 3 dan 5
1. Deklarasi :
i : integer (bilangan 1 - 100)
2. Deskripsi :
Read (i)
i <- 1 - 100
for (int i=1; i<=100; 1++)
if(i mod 3==0)
Write
Else (i mod 5==0)
Write i
Flowchart :
c++ :
1. Deklarasi :
i : integer (bilangan 1 - 100)
2. Deskripsi :
Read (i)
i <- 1 - 100
for (int i=1; i<=100; 1++)
if(i mod 3==0)
Write
Else (i mod 5==0)
Write i
Flowchart :
c++ :
Categories
Tugas PPT
REFLEKSI ALPRO MINGGU KE 4
Pada Minggu Ke 4 ini kami battle sokoban game , meskipun kelompok saya awalnya beruntung dalam permainan itu tapi pada akhirnya kalah juga , tapi walaupun begitu kelompok saya sudah berusaha
yang diperoleh minggu ini :
hari ini saya belajar perulangan (loop)
perulangan for , while , do while
Yang Belum saya pahami :
Saya masih kurang paham coding menggunakan class
Usaha yang dilakukan untuk mengatasinya :
bertanya dengan teman atau kakak tingkat yang mengerti
Categories
Refleksi Alpro
Minggu, 23 Maret 2014
Chapter 3 Ebooks HOW SOLVE IT BY COMPUTER 3.6
Generation of Pseudo-random Numbers
Algoritma :
1. Deklarasi
r : integer (input angka acak)
r,z : integer (output)
2. Deskripsi
read (r)
perulangan
proses c <- 1283
a <- 106
m <- r+1
x <- 1234
z <- ((a*x)+c)%m
write (r,z)
Flowchart :
c++ :
Algoritma :
1. Deklarasi
r : integer (input angka acak)
r,z : integer (output)
2. Deskripsi
read (r)
perulangan
proses c <- 1283
a <- 106
m <- r+1
x <- 1234
z <- ((a*x)+c)%m
write (r,z)
Flowchart :
c++ :
Categories
Tugas Ebooks How To Solve It By Computer
Chapter 3 Ebooks HOW SOLVE IT BY COMPUTER 3.5
Computing the Prime Factors an Integer
Algoritma :
1. Deklarasi
Bil (integer)
2. Deskripsi
Read (Bil)
Bil <- bil / 2
Bil <- bil / 3
Write : Faktorial Prima
Flowchart :
c++ :
Algoritma :
1. Deklarasi
Bil (integer)
2. Deskripsi
Read (Bil)
Bil <- bil / 2
Bil <- bil / 3
Write : Faktorial Prima
Flowchart :
c++ :
Categories
Tugas Ebooks How To Solve It By Computer
Chapter 3 Ebooks HOW SOLVE IT BY COMPUTER 3.4
Generating Prime Numbers
Algoritma :
1. Deklarasi
n : integer (input)
n,i : (output)
2. Deskripsi
read (n)
perulangan
proses i <- 2
i > n
i % 2=0 && i!=2
i%3=0
i<- i + 1
write (n,i)
Flowchart :
c++ :
Algoritma :
1. Deklarasi
n : integer (input)
n,i : (output)
2. Deskripsi
read (n)
perulangan
proses i <- 2
i > n
i % 2=0 && i!=2
i%3=0
i<- i + 1
write (n,i)
Flowchart :
c++ :
Categories
Tugas Ebooks How To Solve It By Computer
Langganan:
Postingan (Atom)