EasyBasicsNot started

Bakery tray packing

A bakery cools its loaves on trays that hold exactly 6 loaves each. At the end of a bake the head baker counts the loaves and wants to know two things: how many trays are completely full, and how many loaves are left on the counter waiting for the next tray.

Read the number of loaves and print both values in the format shown.

Input

One line containing a single integer n, the number of loaves baked.

Output

Two lines: Trays: t where t is the number of full trays, then Left over: r where r is the number of loaves that do not fill a tray.

Example 1

Input

20

Output

Trays: 3
Left over: 2

20 loaves fill 3 trays (18 loaves) and 2 loaves remain.

Example 2

Input

5

Output

Trays: 0
Left over: 5

Five loaves are not enough for a single tray, so all five are left over.

Constraints

  • 0 <= n <= 100000

Hints

Hint 1 of 3

When both operands are int, the / operator throws away the fractional part, which is exactly "how many whole trays".

Hint 2 of 3

The % operator gives the remainder of that division: what is left after the full trays are taken away.

Hint 3 of 3

Print with string interpolation: Console.WriteLine($"Trays: {loaves / 6}");.

Solution

Show a reference solution and explanation
 C# · reference solution
int loaves = int.Parse(Console.ReadLine()!);

int trays = loaves / 6;
int leftOver = loaves % 6;

Console.WriteLine($"Trays: {trays}");
Console.WriteLine($"Left over: {leftOver}");

Why it works

Integer division in C# truncates towards zero, so loaves / 6 is the number of complete trays, and loaves % 6 is the remainder that did not fit. The two operators always agree: (loaves / 6) * 6 + loaves % 6 gives back loaves. Reading the input with int.Parse converts the text line into a number before any arithmetic happens; without that step / would not even compile on a string.

Lesson for this exercise: Variables and Types in C#

Your program
int loaves = int.Parse(Console.ReadLine()!);

// compute the number of full trays and the loaves left over,
// then print the two lines
Run is not available for C# in the browser yet. Write your program here, then download it and run it locally with .NET SDK 8.0 against the examples above. The reference solution below was verified the same way.

Tests: 5 cases including the examples. Passing every test marks the exercise solved in this browser.

How this page was checked. Every program on it was run with .NET SDK 8.0 at build time by the publishing checks, and the output shown is what it printed. Running C# inside the browser is not available yet, so the Run button is absent rather than pretending; copy the code and run it with .NET SDK 8.0 locally.