Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.0 kB
1
Indexable
Never
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int main (){

	int menu, hasil;
	char barang[15];
	printf ("\nMenu : ");
	printf ("\n==== : ");
	printf ("\n1. Total penjualan seluruh barang");
	printf ("\n2. Total penjualan per barang");
	printf("\nMasukkan nomor menu = ");
	scanf ("%d", &menu);
	
	if (menu == 1){
		hasil = (125000*14) + (75000*20) + (1000000*6) + (400000*9);
		printf ("\nTotal penjualan seluruh barang = Rp %d", hasil);
	}
	else if (menu == 2){
		printf("\nMasukkan nama barang = ");
		scanf("%s", &barang);
		if (strcmp(barang, "keyboard") == 0){
			hasil = 125000*14;
		}
		else if (strcmp(barang, "mouse") == 0){
			hasil = 75000*4;
		}
		else if (strcmp(barang, "monitor") == 0){
			hasil = 1000000*6;
		}
		else if (strcmp(barang, "speaker") == 0){
			hasil = 400000*9;
		}
		else {
			printf("\nBarang tidak terdaftar");
		}
		printf ("\nTotal penjualan %s = Rp %d", barang, hasil );
	}
	else {
		printf("\nMenu tidak terdaftar");
	}
	return 0;
}