Algorithm program to print a number that is divisible by 3 and 5 between 1 to 100
1. program will display the statement "a simple program displays a number between 1-100 is divisible by 3 and 5" to the user.
2. after the program returns to call the function process.
3. function check process will be repeated from 100-100 numbers are depleted in the 3 and 5. If the 1-100 number is divisible by 3 and 5 the remainder is o, then the program will display the number and save it as a number. If not the program will ignore these numbers. Repeated until the number 100 in checks. And reverse the total value to the main function as the number of numbers which can be divided into 3 and 5.
4. function reverses the process of value to the function main.
5. program displays the output to the user.
PROGRAM NYA:
#include
#include
class bil{
public:
int proses();
private:
int total;
};
int bil::proses()
{
total=0;
for(int i=1;i<100;i++){
if(i%3==0 && i%5==0)
{
cout<
Algorithm program to print a number that is divisible by 3 and 5 between 1 to 100
simulation program to purchase fuel
simulation program to purchase fuel
task group:
1. Ibnu Abdullah A (10018079)
2. Andri Kurniawan (10018054)
3. Bambang Priyanto (10018039)
4. Beti Wahyu Putro (10018064)
simulation buy fuel with specifications:
Input form:
money / how many liters that will be purchased
Type of fuel to be purchased
Indicators will continue (increasing 0.1liter) for the total price / number of liters of fuel purchased not exceed demand
Output states:
The number of liters purchased (if the input in the form of money)
Total money to be paid (if the input in the form liter)
#include
#include
using namespace std;
int main(int argc, char *argv[])
{
class spbu (){
friend ostream& opreator<<(ostream&,spbu&); friend istream& operator>>(istream&,spbu&);
public :
void banyak();
void pilihan();
void hitung_liter();
void hitung_harga();
private :
int harga;
int Biaya;
int a,b ;
float hasil ;
float premium ;
float solar ;
float pertamax ;
};
void banyak::liter(){
cout<<"Masukkan berapa liter yang dibutuhkan : "; cin>>x;
}
void banyak::pilihan(){
cout<<"pilih 1 untuk premium\n"<<<"pilih 2 untuk solar\n"<<<"pilih 3 untuk pertamax\n"<<<"Masukkan pilihan : "; cin>>y;
}
void banyak::hitung_liter(){
float i = 0.0;
while(i <= x){
i = i + 0.1;
cout<<
}
}
void banyak::hitung_harga(){
float hasil = 0.0;
float premium = 4500;
float solar = 6000;
float pertamax = 8000;
if(y == 1)
hasil = x * premium;
else if(y == 2)
hasil = x * solar;
else if(y == 3)
hasil = x * pertamax;
cout<<"harga : "<<
}
void main(){
spbu :
banyak.banyak();
banyak.harga();
banyak.hitung_liter();
banyak.hitung_harga();
system("PAUSE");
return EXIT_SUCCESS;
}
java program to calculate the factorial
Award as the value of factorial is the result of the multiplication of positive integers less than or equal to the value N. Writing is usually a factorial: n!
berikut programnya :
import jeliot.io.*;
public class faktorial
{
public static void main (String[ ] args)
{
long limit = 20; // menghitung faktorial integer daeri 1 – 20
long faktorial = 1; // pendefinisian variabel faktorial
for (int i = 0; i <= limit; i++)
{
faktorial = 1;
for (int faktor = 2; faktor <= i; faktor ++)
faktorial *= faktor;
System.out.println (i + "!" + " adalah " + faktorial);
}
}
}
Membuat Algoritma
Algoritma yang agag sulit tapi kita mari mencoba.,.,
Berikut soal dan Algoritma yang aku sedang-sedang mencoba,.,
1. algoritma dan program untuk mencari titik tengah sebuah garis yang ujung titiknya adalah A(x1,y1) dan B(x2,y2).
Input = A(x1,y1)
B(x2,y2)
Output = mencetak titik tengah sebuah garis (xT,yT)
• Algoritma
1. masukan x1
2. masukan x2
3. masukan y1
4. masukan y2
5. hitung titik tengah xT
6. hitung titik tengah yT
7. Tampilkan T(xT,yT)
• Program dari Algoritma diatas
#include
class Titik{
friend istream& operator>>(istream& ,Titik&);
friend ostream& operator<<(ostream& ,Titik&);
public:
Titik();
float titik1();
float titik2();
private:
float x1, x2;
float y1, y2;
float TitikTengahx;
float TitikTengahy;
};
Titik::Titik(){
}
float Titik :: titik1(){
TitikTengahx=(x1+x2)/2;
return TitikTengahx;
}
float Titik :: titik2(){
TitikTengahy=(y1+y2)/2;
return TitikTengahy;
}
istream& operator>>(istream& in, Titik& M){
cout<<"PROGRAM MENGHITUNG TITIK TENGAH"<
cout<<"masukkan nilai y1 dan y2 : ";
in>>M.y1>>M.y2;
return in;
}
ostream& operator<<(ostream& out, Titik& M){
out<<"titik tengahnya adalah :("<
cout<
#include
void baca ( int a[][2]);
void tulis (const int a[][2]);
int main() {
int a[2][2];
baca (a);
tulis(a);
return 0;
}
void baca(int a[][2])
{
cout<<”masukan 4 bilangan, 2 bilangan pembaris: \n”;
for(int i=0;i<2;i++){
cout<<”baris”<>a[i][j];
}
}void tulis (const int a[][2] ){
for(int i=0;i<2;i++){
for(int j=0; j<2;j++)
cout<<” “<
cout<
}
mengambil uang di bank
1.
Pada tanggal 8 juni 2010 dilakukan pengecekan pada buku rekening.
2.
Tanggal 24 april 2010 sandi ”satu” debet “tiga juta rupiah” kredit “lima ratus ribu rupiah” jadi “saldo “tiga juta lima ratus ribu rupiah”.
3.
Pergi ke bank (n) .
4.
Mengambil slip pengambilan kemudian diisi fromnya.
5.
Diisi sebanyak jumlah pengambilan sejumlah “dua ratus ribu rupiah”.
6.
Serahkan kepada petugas bank.
7.
Menerima carbon copy slip .
8.
Pengecekan pada buku rekning.
9.
Tanggal 8 juni 2010 sandi “satu” debet “nol” kredit “dua ratus ribu rupiah “ saldo “ dua juta delapan ratusrupiah”.
10.
Menerima uang.
Belajar Algoritma
Algoritma adalah kumpulan urutan perintah yang menentukan operasi-operasi tertentu yang diperlukan untuk menyelesaikan suatu masalah ataupun mengerjakan suatu tugas tertentu. Algoritma merupakan urutan langkah instruksi yang logis.
berikut contoh Algoritma sederhana :
Algoritma membuat kopi:
1.Awalnya sediakan gelas,sendok,kopi dan gula
2.Masukan 2 sendok gula ke dalam gelas
3.Masukan 1 sendok kopi ke dalam gelas
4.Masukan air sampai gelas penuh
5.Aduk hingga kopi dan gula tercampur
6.Minumlah selagi panas
itulah sedikit contoh algoritma sederhana, terima kasih.