0
How to make this? (in the section marked ●●)
menu: 1. chicken 2. pizza 3. burger 4. cola insert your order: 3 you are ordering burger ●●your list 0 chicken 0 pizza 1 burger 0 cola ●●do you want another? [y/n] y then the program will back to 'menu:' and we have to insert the order again, example 3, then the 'your list' part will be updated like this: your list: 0 chicken 0 pizza 2 burger 0 cola
17 odpowiedzi
+ 3
Use a while loop!
Something like this:
int exit = 1;
while(exit != 0)
{
//Do all the code in here to take order etc..
// then after first order you ask for user input again with scanf something like this:
scanf(“%c”, input);
if(input = ‘N’)
exit = 0;
}
//with this if user input N the loop will end and exit program, if input is Y the loop will start again and user can take new order!
+ 5
+ 4
yasifa ana Cuba masuk
3
y
2
y
3
y
1
n
sekali
https://code.sololearn.com/cASR2e6UJ334/?ref=app
+ 3
For SoloLearn codes, you need to enter all inputs at once, like I show you in my previous message.
+ 1
I think code playground only allow one time start up input for non web program.
+ 1
yasifa ana yes you can do as Calviղ showed you.
If you want to repeat the action you can use a while loop.. but that will work only if you run the code on a compiler in your computer, it dont work in code playground on sololearn!
0
You should try to write the code on your own first, then show us and ask for help on part you did/do not understand and eventual error!
If you dont know where to start on how to do it:
You should first declare an array with the menu inside, then check for user input, then you could use either a switch statement or an if statement to determine which is the choice of the user and then increment a counter variable for the choice made!
Also if you have not done yet, you should take the sololearn course on C, it will give you the basic understanding on the language so you can write the program on your own 😉
0
Sekiro I made the program, but in that part I don't know how to make that part
https://code.sololearn.com/cYgrLssEYBpL/?ref=app
that is the program, it's in indonesian laguange, the meaning is same as in the description
0
Sekiro 'list pesanan anda' mean 'your list', and I dont know how to do that part
0
Calviղ okaay, I get it...
and the next problem for me is, when we want to make another 'pesanan', y for yes(make another 'pesanan') and n for no(don't make another 'pesanan')
is it using string? but how:'
Im sorry for my language😣
0
Calviղ thank you so much
but how to make it go to the top again after we input the 'y'?
and after we input the 'y', the program just display the same thing from the start(the other that has been shown disappears) how to do that?
0
Calviղ no, I mean, your code is work when i try on my laptop,, and I just ask how to make the program only display like the first we run the program when we input 'y' to the program.
when we first run the program:
'paket chicken holic'
.
.
.
'mau pesan apa?'
.
.
.
'masukkan pesan lagi?'
now, we input the 'y'
and how to make the program not continue in the below ?
program continue in the below:
'paket chicken holic'
.
.
.
'mau pesan apa?'
.
.
.
'masukkan pesan lagi?'
y
'paket chicken holic'
.
.
.
'mau pesan apa?'
.
.
.
'masukkan pesan lagi?'
your code turn out like that
and i ask how to make the program like this:
'paket chicken holic'
.
.
.
'mau pesan apa?'
.
.
.
'masukkan pesan lagi?'
y
all of the above will disappear and will appear:
'paket chicken holic'
.
.
.
'mau pesan apa?'
.
.
.
'masukkan pesan lagi?'
0
You can make a function called display Order. Call it when the orders are completed.
https://code.sololearn.com/c6810OUi8noB/?ref=app
0
Calviղ no, your code (QnA3) is what I mean
do you know indonesia or melayu language? if you know, i will explain what I mean, because i cant explain it in english:'
0
I know bahasa melayu
0
Calviղ jadi saya mau supaya program itu tidak dilanjut ke bawah, tapi seperti mulai awal lagi,, tapi nilai yang sudah di input tetap tersimpan,, dan apabila kita pesan menu sama, itu jumlahnya akan bertambah
misalkan:
kita mulai program
akan tampil 'paket chicken holic' sampai 'mau pesan apa'
lalu kita input nak pesan apa
setelah itu muncul 'berhasil memesan' sampai 'masukkan pesan lagi?'
disinilah letak masalahnya, apabila kita input 'y', program akan menampilkan 'paket chicken holic' sampai seterusnya di bawah 'masukkan pesan lagi'
nah, bagaimana jika 'paket chicken holic' itu tidak dibawah tapi kembali ke atas,, dan tulisan yang sudah berlalu itu tidak ditampilkan lagi.
kalau dilanjutkan di bawah itu, kita bisa scroll ke atas untuk lihat masukan yang telah kita input,, tapi jika tidak dilanjutkan ke bawah itu, semua tulisan dan masukan itu tidak bisa kita lihat lagi
itu bagaimana? aku dah cari di internetpun tak ada:'