Hi can this code be converted to Java? #include <stdio.h> struct customer { int
ID: 3702303 • Letter: H
Question
Hi can this code be converted to Java?
#include <stdio.h>
struct customer
{
int customer_id;
char customer_name[50];
float customer_balance;
};
struct casino
{
int casino_id;
char name[20];
float casino_bal;
// structure within structure//
struct customer s;
}cas;
int new_customer();
int new_casino();
int change_customer();
int change_casino();
int play_game();
int display_customer();
int display_casino();
float total_bal, cust_bal, customer_bal;
int main()
{
int choice;
printf(“ Enter your choice ”);
scanf(“%d”, &choice);
while(1)
{
printf(“*******1. new_customer************”);
printf(“*******2. new_casino ************”);
printf(“*******3. change_customer ************”);
printf(“*******4. change_casino ************”);
printf(“*******5. play_game ************”);
printf(“*******6. display_customer ************”);
printf(“*******7. display_casino ************”);
//******MENU DRIVEN PROGRAM********
switch(choice)
{
case 1:
new_customer();
break;
case 2:
new_casino();
break;
case 3:
change_customer();
break;
case 4:
change_casino();
break;
case 5:
play_game();
break;
case 6:
display_customer();
break;
case 7:
display_casino();
break;
default:
printf("Enter the customer_name ");
printf(“Balance=1000”);
printf("Enter the casino name ");
printf(“Balance=50000”);
break;
}
}
}
int new_customer()
{
printf("Enter name: ");
scanf("%s", s.casino_name);
printf("Enter the id: ");
scanf("%d", &s.customer_id);
printf("Enter monetary balance: ");
scanf("%f", &s.customer_bal);
}
int new_casino()
{
printf("Enter name: ");
scanf("%s", cas.s.customer_name);
printf("Enter the id: ");
scanf("%d", & cas.s.casino_id);
printf("Enter monetary balance: ");
scanf("%f", & cas.s.casino_bal);
total_bal= casino_bal – 15000;
printf(“Balance of casino=%f”,total_bal);
cust_bal= customer_bal+15000;
printf(“%f”,cust_bal);
}
int change_customer()
{
printf(“Name=%s”,customer_name);
printf(“Balance=%f”,customer_balance);
}
int change_casino()
{
printf(“Name=%s”,casino_name);
printf(“Balance=%f”,casino_balance);
}
int play_game()
{
printf(“ Showing the different games ”);
printf(“****TWENTY ONE GAME***********”);
printf(“****HIGH LOW GAME***********”);
printf(“****SEVEN ELEVEN GAME***********”);
If(player= =7 ||player==11)
Printf(“Roll 7or 11 wins”);
If(player !=7 || player!=11)
Printf(“Roll Again ”);
If(player= =7 || player==11)
Printf(“Roll Again ”);
If(player= =7 &&player==11)
Printf(“Roll 11 wins”);
printf(“****SLOT GAME***********”);
}
int display_customer()
{
printf("Enter name: ");
printf ("%s", s[i].casino_name);
printf("Enter the id: ");
printf("%d", s[i].customer_id);
printf("Enter monetary balance: ");
printf ("%f", s[i].customer_bal);
}
int display_casino()
{
printf("showing name: ");
printf ("%s", cas[i].s[i].customer_name);
printf("showing the id: ");
printf("%d", cas[i].s[i].casino_id);
printf("showing monetary balance: ");
printf("%f", &cas[i].s[i].casino_bal);
}
Explanation / Answer
Your C code does not compile so it is not possible not possible at the face of it.
But once you successfully run your program you can try to do the following:
.....
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.