SlideShare a Scribd company logo
1 of 2
Download to read offline
Latihan 11
#include<iostream>
#include<conio.h>
#include<iomanip>
#include <windows.h >
using namespace std;
void gotoxy(int x, int y)
{
COORD coord;
coord.X=x;
coord.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}
int main()
{
char nama[30], barang[30];
int jumlah_barang, jumlah_beli = 0;
long harga_satuan, jumlah_harga, total_bayar = 0;
cout << "=== TOKO SERBA ADA === " << endl;
cout << "Nama Pembeli : " << endl;
cout << "Jumlah Barang yg Dibeli : " << endl;
gotoxy (27,1); cin >> nama;
gotoxy (27,2); cin >> jumlah_barang;
cout << endl;
cout << "=====================================================================" << endl;
cout << " | NO | NAMA BARANG | JUMLAH BELI | HARGA SATUAN | JUMLAH HARGA |" << endl;
cout << "=====================================================================" << endl;
for (int i = 1; i <= jumlah_barang; i++) {
gotoxy(1,i+6); cout << "|";
gotoxy(6,i+6); cout << "|";
gotoxy(24,i+6); cout << "|";
gotoxy(38,i+6); cout << "|";
gotoxy(53,i+6); cout << "|";
gotoxy(68,i+6); cout << "|";
gotoxy(3,i+6); cout << setw(2) << i;
}
cout << endl;
cout << "=====================================================================" << endl;
cout << " | TOTAL | |" << endl;
cout << "=====================================================================" << endl;
for (int j = 1; j <= jumlah_barang; j++) {
gotoxy(8,j+6); cin >> barang;
gotoxy(26,j+6); cin >> jumlah_beli;
gotoxy(40,j+6); cin >> harga_satuan;
jumlah_harga = jumlah_beli * harga_satuan;
gotoxy(55,j+6); cout << setw(12) << jumlah_harga;
total_bayar = total_bayar + jumlah_harga;
}
gotoxy(55,jumlah_barang+8); cout << setw(12) << total_bayar << endl;
gotoxy(1,jumlah_barang+11);cout << "TERIMA KASIH";
getch();
}
Permintaan:
1. Tambahkan informasi DISKON dan TOTAL BAYAR, dibawah informasi TOTAL
- DISKON didapat dari jika TOTAL lebih dari 10000, maka DISKON 10% dari TOTAL, jika tidak 0
- TOTAL BAYAR didapat dari TOTAL - DISKON
2. Buatkan Menu tambah data lagi, "INPUT DATA LAGI [Y/T]”

More Related Content

What's hot (6)

The Ring programming language version 1.5.4 book - Part 41 of 185
The Ring programming language version 1.5.4 book - Part 41 of 185The Ring programming language version 1.5.4 book - Part 41 of 185
The Ring programming language version 1.5.4 book - Part 41 of 185
 
MongoDB全機能解説2
MongoDB全機能解説2MongoDB全機能解説2
MongoDB全機能解説2
 
Types, Operators and Primitives
Types, Operators and PrimitivesTypes, Operators and Primitives
Types, Operators and Primitives
 
Core dev summit
Core dev summitCore dev summit
Core dev summit
 
The Ring programming language version 1.5.4 book - Part 42 of 185
The Ring programming language version 1.5.4 book - Part 42 of 185The Ring programming language version 1.5.4 book - Part 42 of 185
The Ring programming language version 1.5.4 book - Part 42 of 185
 
Rumus VB-2
Rumus VB-2Rumus VB-2
Rumus VB-2
 

Similar to Latihan C++ menggunakan setConsoleCursorPosition

Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdf
HIMANSUKUMAR12
 
Please use the code below and make it operate as one program- Notating.pdf
Please use the code below and make it operate as one program- Notating.pdfPlease use the code below and make it operate as one program- Notating.pdf
Please use the code below and make it operate as one program- Notating.pdf
seoagam1
 
So I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdfSo I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdf
arjuncollection
 
ch5_additional.ppt
ch5_additional.pptch5_additional.ppt
ch5_additional.ppt
LokeshK66
 
Programa.eje
Programa.ejePrograma.eje
Programa.eje
guapi387
 
Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++
Dendi Riadi
 
This code has nine errors- but I don't know how to solve it- Please gi (1).pdf
This code has nine errors- but I don't know how to solve it- Please gi (1).pdfThis code has nine errors- but I don't know how to solve it- Please gi (1).pdf
This code has nine errors- but I don't know how to solve it- Please gi (1).pdf
aamousnowov
 

Similar to Latihan C++ menggunakan setConsoleCursorPosition (20)

File Handling Program
File Handling ProgramFile Handling Program
File Handling Program
 
C++ practical
C++ practicalC++ practical
C++ practical
 
Penjualan swalayan
Penjualan swalayanPenjualan swalayan
Penjualan swalayan
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 
Oop lab report
Oop lab reportOop lab report
Oop lab report
 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdf
 
Cpp c++ 1
Cpp c++ 1Cpp c++ 1
Cpp c++ 1
 
Please use the code below and make it operate as one program- Notating.pdf
Please use the code below and make it operate as one program- Notating.pdfPlease use the code below and make it operate as one program- Notating.pdf
Please use the code below and make it operate as one program- Notating.pdf
 
C++ L05-Functions
C++ L05-FunctionsC++ L05-Functions
C++ L05-Functions
 
So I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdfSo I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdf
 
C++ L03-Control Structure
C++ L03-Control StructureC++ L03-Control Structure
C++ L03-Control Structure
 
ch5_additional.ppt
ch5_additional.pptch5_additional.ppt
ch5_additional.ppt
 
Programa.eje
Programa.ejePrograma.eje
Programa.eje
 
Notes
NotesNotes
Notes
 
Array notes
Array notesArray notes
Array notes
 
Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++
 
Programs of C++
Programs of C++Programs of C++
Programs of C++
 
This code has nine errors- but I don't know how to solve it- Please gi (1).pdf
This code has nine errors- but I don't know how to solve it- Please gi (1).pdfThis code has nine errors- but I don't know how to solve it- Please gi (1).pdf
This code has nine errors- but I don't know how to solve it- Please gi (1).pdf
 
JavaScript Objects and OOP Programming with JavaScript
JavaScript Objects and OOP Programming with JavaScriptJavaScript Objects and OOP Programming with JavaScript
JavaScript Objects and OOP Programming with JavaScript
 
Opp compile
Opp compileOpp compile
Opp compile
 

More from Achmad Sidik (6)

Program Kasir c++(case ROti88)
Program Kasir c++(case ROti88)Program Kasir c++(case ROti88)
Program Kasir c++(case ROti88)
 
Menghitung Luas Bangunan dengan C++
Menghitung Luas Bangunan dengan C++Menghitung Luas Bangunan dengan C++
Menghitung Luas Bangunan dengan C++
 
Membuat Aplikasi dengan C++
Membuat Aplikasi dengan C++Membuat Aplikasi dengan C++
Membuat Aplikasi dengan C++
 
Program menghitung angka genap dengan C++
Program menghitung angka genap dengan C++Program menghitung angka genap dengan C++
Program menghitung angka genap dengan C++
 
CRUD VB2010
CRUD VB2010CRUD VB2010
CRUD VB2010
 
CRUD dengan asp classic
CRUD dengan asp classicCRUD dengan asp classic
CRUD dengan asp classic
 

Recently uploaded

Recently uploaded (20)

Rapidoform for Modern Form Building and Insights
Rapidoform for Modern Form Building and InsightsRapidoform for Modern Form Building and Insights
Rapidoform for Modern Form Building and Insights
 
Abortion Pill Prices Mthatha (@](+27832195400*)[ 🏥 Women's Abortion Clinic In...
Abortion Pill Prices Mthatha (@](+27832195400*)[ 🏥 Women's Abortion Clinic In...Abortion Pill Prices Mthatha (@](+27832195400*)[ 🏥 Women's Abortion Clinic In...
Abortion Pill Prices Mthatha (@](+27832195400*)[ 🏥 Women's Abortion Clinic In...
 
Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
 
Abortion Clinic In Springs ](+27832195400*)[ 🏥 Safe Abortion Pills in Springs...
Abortion Clinic In Springs ](+27832195400*)[ 🏥 Safe Abortion Pills in Springs...Abortion Clinic In Springs ](+27832195400*)[ 🏥 Safe Abortion Pills in Springs...
Abortion Clinic In Springs ](+27832195400*)[ 🏥 Safe Abortion Pills in Springs...
 
Abortion Pill Prices Germiston ](+27832195400*)[ 🏥 Women's Abortion Clinic in...
Abortion Pill Prices Germiston ](+27832195400*)[ 🏥 Women's Abortion Clinic in...Abortion Pill Prices Germiston ](+27832195400*)[ 🏥 Women's Abortion Clinic in...
Abortion Pill Prices Germiston ](+27832195400*)[ 🏥 Women's Abortion Clinic in...
 
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale IbridaUNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
 
The Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test AutomationThe Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test Automation
 
From Knowledge Graphs via Lego Bricks to scientific conversations.pptx
From Knowledge Graphs via Lego Bricks to scientific conversations.pptxFrom Knowledge Graphs via Lego Bricks to scientific conversations.pptx
From Knowledge Graphs via Lego Bricks to scientific conversations.pptx
 
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
 
Software Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements EngineeringSoftware Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements Engineering
 
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
 
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
 
GraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4jGraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4j
 
Abortion Pill Prices Turfloop ](+27832195400*)[ 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Turfloop ](+27832195400*)[ 🏥 Women's Abortion Clinic in ...Abortion Pill Prices Turfloop ](+27832195400*)[ 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Turfloop ](+27832195400*)[ 🏥 Women's Abortion Clinic in ...
 
Microsoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdfMicrosoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdf
 
Transformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with LinksTransformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with Links
 
Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?
 
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCAOpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
 
Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...
Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...
Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...
 
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
 

Latihan C++ menggunakan setConsoleCursorPosition

  • 1. Latihan 11 #include<iostream> #include<conio.h> #include<iomanip> #include <windows.h > using namespace std; void gotoxy(int x, int y) { COORD coord; coord.X=x; coord.Y=y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord); } int main() { char nama[30], barang[30]; int jumlah_barang, jumlah_beli = 0; long harga_satuan, jumlah_harga, total_bayar = 0; cout << "=== TOKO SERBA ADA === " << endl; cout << "Nama Pembeli : " << endl; cout << "Jumlah Barang yg Dibeli : " << endl; gotoxy (27,1); cin >> nama; gotoxy (27,2); cin >> jumlah_barang; cout << endl; cout << "=====================================================================" << endl; cout << " | NO | NAMA BARANG | JUMLAH BELI | HARGA SATUAN | JUMLAH HARGA |" << endl; cout << "=====================================================================" << endl; for (int i = 1; i <= jumlah_barang; i++) { gotoxy(1,i+6); cout << "|"; gotoxy(6,i+6); cout << "|"; gotoxy(24,i+6); cout << "|"; gotoxy(38,i+6); cout << "|"; gotoxy(53,i+6); cout << "|"; gotoxy(68,i+6); cout << "|"; gotoxy(3,i+6); cout << setw(2) << i; } cout << endl; cout << "=====================================================================" << endl; cout << " | TOTAL | |" << endl; cout << "=====================================================================" << endl; for (int j = 1; j <= jumlah_barang; j++) { gotoxy(8,j+6); cin >> barang; gotoxy(26,j+6); cin >> jumlah_beli;
  • 2. gotoxy(40,j+6); cin >> harga_satuan; jumlah_harga = jumlah_beli * harga_satuan; gotoxy(55,j+6); cout << setw(12) << jumlah_harga; total_bayar = total_bayar + jumlah_harga; } gotoxy(55,jumlah_barang+8); cout << setw(12) << total_bayar << endl; gotoxy(1,jumlah_barang+11);cout << "TERIMA KASIH"; getch(); } Permintaan: 1. Tambahkan informasi DISKON dan TOTAL BAYAR, dibawah informasi TOTAL - DISKON didapat dari jika TOTAL lebih dari 10000, maka DISKON 10% dari TOTAL, jika tidak 0 - TOTAL BAYAR didapat dari TOTAL - DISKON 2. Buatkan Menu tambah data lagi, "INPUT DATA LAGI [Y/T]”