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

16th Dec 2018, 2:39 AM
yasifa ana
17 Respostas
+ 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!
16th Dec 2018, 8:45 AM
Sekiro
Sekiro - avatar
16th Dec 2018, 6:27 AM
Calviղ
Calviղ - avatar
16th Dec 2018, 8:55 AM
Calviղ
Calviղ - avatar
+ 3
For SoloLearn codes, you need to enter all inputs at once, like I show you in my previous message.
16th Dec 2018, 9:28 AM
Calviղ
Calviղ - avatar
+ 1
I think code playground only allow one time start up input for non web program.
16th Dec 2018, 7:51 AM
Calviղ
Calviղ - avatar
+ 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!
16th Dec 2018, 7:59 AM
Sekiro
Sekiro - avatar
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 😉
16th Dec 2018, 2:56 AM
Sekiro
Sekiro - avatar
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
16th Dec 2018, 3:52 AM
yasifa ana
0
Sekiro 'list pesanan anda' mean 'your list', and I dont know how to do that part
16th Dec 2018, 3:54 AM
yasifa ana
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😣
16th Dec 2018, 6:41 AM
yasifa ana
0
Calviղ Sekiro okaay,, but if you know how to do that, can you tell me? Im stuck in that part:'
16th Dec 2018, 8:04 AM
yasifa ana
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?
16th Dec 2018, 9:25 AM
yasifa ana
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?'
16th Dec 2018, 9:53 AM
yasifa ana
0
You can make a function called display Order. Call it when the orders are completed. https://code.sololearn.com/c6810OUi8noB/?ref=app
16th Dec 2018, 10:09 AM
Calviղ
Calviղ - avatar
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:'
16th Dec 2018, 10:19 AM
yasifa ana
0
I know bahasa melayu
16th Dec 2018, 10:25 AM
Calviղ
Calviղ - avatar
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:'
16th Dec 2018, 10:42 AM
yasifa ana