0

9.3 Practice Beer party C#

I'm new to this and I'm having a problem getting past this. Maybe I don't understand how the test cases work because I'm unsure how to get 3 different inputs and 3 outputs at the same time on one line.

23rd Jun 2021, 2:27 PM
Ronald
Ronald - avatar
7 Respuestas
+ 1
Pls show your code here
23rd Jun 2021, 3:03 PM
🤴🌹Cute Princess 🌹💐
🤴🌹Cute Princess  🌹💐 - avatar
+ 1
Thank you! I am getting the hang of it. I guess I didn’t understand how the test cases worked. I just used this to get it to work: namespace Code_Coach_Challenge { class Program { static void Main(string[] args) { //your code goes here double x; x = Convert.ToDouble(Console.ReadLine()); Console.WriteLine(x % 7); } } }
24th Jun 2021, 12:19 AM
Ronald
Ronald - avatar
+ 1
Yes. it works. This is code asked to write.. .👍
24th Jun 2021, 9:53 PM
Jayakrishna 🇮🇳
0
Initially, I just got one result. However, it failed the other two test cases, so then I put this... namespace Code_Coach_Challenge { class Program { static void Main(string[] args) { //your code goes here int x = 30; while (x <= 40) { Console.WriteLine(x % 7); x+=5; } } } } It didn't work because you get three outputs on a different line. However, I don't understand how I can get 1 output to satisfy all three test cases.
23rd Jun 2021, 3:07 PM
Ronald
Ronald - avatar
0
What is the problem description?
23rd Jun 2021, 3:35 PM
Jayakrishna 🇮🇳
0
It's using the modulus operator. Here is the problem: Modulus You're organizing a party for 7 guests. All of them like beer. Write a program to take the number of beer bottles you bought as input and calculate how many bottles will be left after equally distributing the beer among all guests. Sample Input 30 Sample Output 2 Use modulus operator % to calculate the remainder. Here are the test cases: Test Case 1 Input 40 Your Output 2 Expected Output 5 Test Case 2 Input 30 Your Output 2 Expected Output 2 Test Case 3 Input 35 Your Output 2 Expected Output 0 If I can clearly get one, I don't understand how I can get all of them at the same time. As I mentioned, maybe I'm not clear on how the test cases work.
23rd Jun 2021, 4:24 PM
Ronald
Ronald - avatar
0
Ronald Test cases not applied all at ones. You have to write program which works for any input , and should give correct output. In your code, first you have to take input values into a variable say x. Let's input is 40 then find remaining and print result Console.Write( x%7); That's it. It will be tested *running again* with other sample inputs... on 40 => must output x%7 => 5 on 30 => must output x%7 => 2 on 35 => must output x%7 => 0 .. so there you need to take input and no need of loop.
23rd Jun 2021, 8:56 PM
Jayakrishna 🇮🇳