Laporan Praktikum 2

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Nama : Yusriyyah Nabilafifah

NIM : A1C022010
Kelompok : 4
Asprak : Abdan
POSTTEST PRAKTIKUM PEMROGRAMAN KOMPUTER ACARA 3 & 4

1. Soal Nomor 2
a. Program
#include <iostream>
#include <stdlib.h>
using namespace std;

int main()
{
int skor1, skor2, skor3, skor4, skor5;
string nama1 = "liverpool";
string nama2 = "arsenal";
string nama3 = "Brighton";
string nama4 = "Manchester City";
string nama5 = "Manchester United";

cout << "Yusriyyah Nabilafifah/A1C022010/Kelompok 4/Abdan\n";


cout << "\n==== SKOR TIM LIGA INGGRIS ====\n\n";
cout << nama1;
cout << ":";
cin >> skor1;
cout << nama2;
cout << ":";
cin >> skor2;
cout << nama3;
cout << ":";
cin >> skor3;
cout << nama4;
cout << ":";
cin >> skor4;
cout << nama5;
cout << ":";
cin >> skor5;
cout << "\n\n";
cout << "=== STATUS TIM ===\n\n";

if (skor1 < 20) {


cout << nama1;
cout << ": Terdegradasi\n";
}
else if (skor1 <= 50) {
cout << nama1;
cout << ": Masuk zona playoff UCL\n";
}
else if (skor1 > 50) {
cout << nama1;
cout << ": Masuk zona UCL\n";
}

if (skor2 < 20) {


cout << nama2;
cout << ": Terdegradasi\n";
}
else if (skor2 <= 50) {
cout << nama2;
cout << ": Masuk zona play off UCL\n";
}
else if (skor2 > 50) {
cout << nama2;
cout << ": Masuk zona UCL\n";
}
if (skor3 < 20) {
cout << nama3;
cout << ": Terdegradasi\n";
}
else if (skor3 <= 50) {
cout << nama3;
cout << ": Masuk zona play off UCL\n";
}
else if (skor3 > 50) {
cout << nama3;
cout << ": Masuk zona UCL\n";
}

if (skor4 < 20) {


cout << nama4;
cout << ": Terdegradasi\n";
}
else if (skor4 <= 50) {
cout << nama4;
cout << ": Masuk zona play off UCL\n";
}
else if (skor4 > 50) {
cout << nama4;
cout << ": Masuk zona UCL\n";
}

if (skor5 < 20) {


cout << nama5;
cout << ": Terdegradasi\n";
}
else if (skor5 <= 50) {
cout << nama5;
cout << ": Masuk zona play off UCL\n";
}
else if (skor5 > 50) {
cout << nama5;
cout << ": Masuk zona UCL\n";
}

cout << "\n\n\nJUARA LIGA INGGRIS:\n\n";


cout << " * * \n";
cout << " * ## ### ## \n";
cout << " ### ##### ### * \n";
cout << " * * ############ * \n";
cout << " ########## * \n";
cout << " ######################################\n";
cout << " # ### # ######## # ### #\n";
cout << " # # ## ################ ## # #\n";
cout << " ######################################\n";
cout << " # ######################## #\n";
cout << " # * #################### #\n";

cout << " ";

if (skor1 > skor2 && skor1 > skor3 && skor1 > skor4 && skor1 > skor5){
cout << nama1;
}
else if (skor2 > skor3 && skor2 > skor4 && skor2 > skor5) {
cout << nama2;
}
else if (skor3 > skor4 && skor3 > skor5) {
cout << nama3;
}
else if (skor4 > skor5) {
cout << nama4;
}
else {
cout << nama5;
}

cout << "\n";


cout << " # #################### # \n";
cout << " # * ################## # \n";
cout << " # ################ * # \n";
cout << " # ################ # \n";
cout << " # * ############## # *\n";
cout << " * # ############ # \n";
cout << " * # ########## # * \n";
cout << " # ######## * # \n";
cout << " * ## ###### ## * \n";
cout << " ############ * \n";
cout << " * ############## \n";
cout << " ################ * \n";

}
Gambar 1. Screenshot program soal nomor 2.
b. Hasil Running

Gambar 2. Screenshot Hasil running program nomor 2.


2. Soal Nomor 4
a. Program
#include <iostream>
using namespace std;

int main() {
double m, panjang, lebar, g = 10.0;

cout << "Yusriyyah Nabilafifah/A1C022010/Kelompok 4/Abdan\n";

cout << "Masukkan massa (m): ";


cin >> m;

cout << "Masukkan panjang: ";


cin >> panjang;

cout << "Masukkan lebar: ";


cin >> lebar;

double gaya = m * g;
double luasPermukaan = panjang * lebar;
double tekanan = gaya / luasPermukaan;

cout << "Gaya: " << gaya << endl;


cout << "Luas Permukaan: " << luasPermukaan << endl;
cout << "Tekanan: " << tekanan << endl;

return 0;
}

Gambar 3. Screenshot program soal nomor 4.


b. Hasil Running

Gambar 4. Screenshot Hasil running program soal nomor 4.

You might also like