Dek-D.com ใช้คุกกี้เพื่อพัฒนาประสบการณ์ของ
ผู้ใช้ให้ดียิ่งขึ้น เรียนรู้เพิ่มเติมที่นี่
ยอมรับ

ช่วยผมด้วยคับจะ ม.ส. แล้ว โปรแกรม c++

ตั้งกระทู้ใหม่
ตั้งกระทู้ใหม่
โปรแกรมมันเพี้ยน

เงื่อนไขที่ 1 ใช้น้ำไม่เกิน 10 หน่วย ไม่เสียค่าน้ำประปา

เงื่อนไขที่ 2 ใช้น้ำไม่เกิน 20 หน่วย คิดหน่วยละ 5 บาท โดยคิดรวมทั้ง 10 หน่วยแรกด้วย

เงื่อนไขที่ 3 ใช้น้ำที่เกินจาก 20 หน่วยแรก แต่ไม่เกิน 40 หน่วย คิดหน่วยละ 7 บาท

เงื่อนไขที่ 4 ใช้น้ำที่เกินจาก 40 หน่วยแรก แต่ไม่เกิน 100 หน่วย คิดหน่วยละ 10 บาท

เงื่อนไขที่ 5 ใช้น้ำที่เกินจาก 100 หน่วยขึ้นไปคิดหน่วยละ 15 บาท

การคำนวณหาค่าน้ำประปา โดยให้คำนวณหาจำนานเงินที่จะต้องจ่าย(ก่อนบวกค่าบริการและภาษีมูลค่าเพิ่ม 7%) จากนั้นให้นำค่าที่ได้มาบวกกับค่าบริการ และบวกกับภาษีมูลค่าเพิ่ม 7% แล้วนำมาแสดงผลลัพธ์เป็นเป็นค่าน้ำประปาทั้งหมดที่ต้องจ่าย

นี้โค้ดโปรแกรมคับ


#include<stdio.h>
#define VAT 7.0
#include<conio.h>
main()
{


int unit, unit_use, pay=0, service_charge;
char choice;
float bill = 0;

do
{
clrscr();

textcolor(4);
gotoxy (1,1);
cprintf("๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ");
gotoxy(1,2);
cprintf("๏ฟฝ๏ฟฝ๏ฟฝ๏ฟ input data ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ bill ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ");
gotoxy(1,3);
cprintf("_______________________________________________________________________________");
textcolor(10);
gotoxy(1,4);
cprintf(" ");
gotoxy(1,5);
cprintf(" ");
gotoxy(1,6);
cprintf(" ");
gotoxy(1,7);
cprintf(" ");
gotoxy(1,8);
cprintf(" ");
gotoxy(1,9);
cprintf(" ");
gotoxy(1,10);
cprintf(" ");
gotoxy(1,11);
cprintf(" ");
gotoxy(1,12);
cprintf(" ");
gotoxy(1,13);
cprintf(" ");
gotoxy(1,14);
cprintf("_______________________________________________________________________________");
gotoxy(1,16);
cprintf(" >> Water Price <<");
gotoxy(1,17);
cprintf("Use water 10 unit not waste money ");
gotoxy(1,18);
cprintf("Use water 20 unit 5 Baht per unit Include the first 10 units. ");
gotoxy(1,19);
cprintf("Use water exceeds 20 units. Not exceeding 40 units, 7 Baht per unit. ");
gotoxy(1,20);
cprintf("Use water exceeds 40 units. Not exceeding 100 units, 10 Baht per unit. ");
gotoxy(1,21);
cprintf("Use water that exceeds 100 units, representing 15 units. ");



textcolor(4);
gotoxy(7,5);
cprintf("\n Enter water unit : ");
scanf("%d", &unit);

if(unit > 100){
unit_use = unit - 100;
pay += unit_use * 15;
unit -= unit_use;
}

if(unit > 40 && unit <= 100){
unit_use = unit - 40;
pay += unit_use * 10;
unit -= unit_use;
}

if(unit > 20 && unit <= 40){
unit_use = unit - 20;
pay = unit_use * 7;
unit -= unit_use;
}

if(unit > 10){
pay += unit * 5;
}
textcolor(6);
gotoxy(7,9);
cprintf(" Enter Service charge : ");
scanf("%d", &service_charge);

textcolor(7);
gotoxy(41,6);
bill = pay + service_charge;
cprintf(" bill before VAT is %.2f Bath", bill);
textcolor(8);
gotoxy(41,9);
bill = bill * ( 1 + (VAT / 100));
printf(" VAT %.2f%% is %.2f Bath", VAT, (bill * VAT) / (100+VAT));
gotoxy(41,11);
printf(" Total water bill is %.2f Bath\n", bill);

gotoxy(1,23);
printf("\n\n Select Continue (0=Exit,1=next) ");
choice=getche();
}
while(choice != '0');
return 0;


}

มันคำนวณผิดคับ ผมใส่ 122 ค่าบริการ0 มัน คำนวณออกมาไม่ตรงกับที่อาจารคำนวณ


จะม.ส 4 โมงคับ โปรแกรม c++

แสดงความคิดเห็น

>