salam,
ade tak sape2 boleh tolong tukarkan skrip C++ dibawah ini kepada skrip C
#include <iostream>
#include <cmath>
#include <conio.h>
using namespace std;
int main()
{
int account;
char code;
double gallons, bill;
cout << "Enter your account number:" << endl;
cin >> account;
cout << "Now enter your code(h,c, or i):" << endl;
cin >> code;
cout << "Now enter the amount of gallons of water used:" << endl;
cin >> gallons;
if (code == 'h')
{
bill = 5 + (gallons * 0.0005);
**
if (code == 'c' && gallons > 4000000)
{
bill = 1000 + ((gallons - 4000000) * 0.00025);
**
else if (code == 'c' && gallons <= 4000000)
{
bill = 1000;
**
if (code == 'i' && gallons <= 4000000)
{
bill = 1000;
**
else if (code == 'i' && gallons < 4000000 && gallons > 10000000)
{
bill = 2000;
**
else if (code == 'i' && gallons >= 10000000)
{
bill = 3000;
**
cout << "The bill for account number: " << account << ", will be: $" << bill << endl;
getch();
return 0;
**
ade tak sape2 boleh tolong tukarkan skrip C++ dibawah ini kepada skrip C
#include <iostream>
#include <cmath>
#include <conio.h>
using namespace std;
int main()
{
int account;
char code;
double gallons, bill;
cout << "Enter your account number:" << endl;
cin >> account;
cout << "Now enter your code(h,c, or i):" << endl;
cin >> code;
cout << "Now enter the amount of gallons of water used:" << endl;
cin >> gallons;
if (code == 'h')
{
bill = 5 + (gallons * 0.0005);
**
if (code == 'c' && gallons > 4000000)
{
bill = 1000 + ((gallons - 4000000) * 0.00025);
**
else if (code == 'c' && gallons <= 4000000)
{
bill = 1000;
**
if (code == 'i' && gallons <= 4000000)
{
bill = 1000;
**
else if (code == 'i' && gallons < 4000000 && gallons > 10000000)
{
bill = 2000;
**
else if (code == 'i' && gallons >= 10000000)
{
bill = 3000;
**
cout << "The bill for account number: " << account << ", will be: $" << bill << endl;
getch();
return 0;
**
