Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add While Loops HW #1451

Open
wants to merge 1 commit into
base: pb-java-march-20
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions EN/05-While-Loop/07-Homework.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ Create a program that:
| Winnie the Pooh | |
| Peter Pan | |
| Alice in Wonderland | |

[hints]
[hint]
Firstly read the title of the book.
[/hint]
[hint]
Then using a **while loop**, keep reading titles until you receive the same one as in the start. Keep track of the attempts and print them at the end!
[/hint]
[/hints]

[/task-description]
[tests]
[test open]
Expand Down Expand Up @@ -298,6 +308,17 @@ Create a program that:
| 23 | 23 is not special |
| 404 | 404 is special |

[hints]
[hint]
Using a while loop, iterate over every digit of the number.
[/hint]
[hint]
You can get each of the digits using: int lastDigit = number % 10; number /= 10;
[/hint]
[hint]
In the end, print if the number is special or not.
[/hint]
[/hints]

[/task-description]
[tests]
Expand Down Expand Up @@ -447,6 +468,22 @@ Create a program that:
| 8 | 1 |
| | 3 |
| | 7 |

[hints]
[hint]
The condition of your while loop should be (<= n)
[/hint]
[hint]
```java
while (2*num+1<=n)
{
num = num * 2 + 1;
(...)
}
```
[/hint]
[/hints]

[/task-description]
[tests]
[test open]
Expand Down Expand Up @@ -561,6 +598,16 @@ Create a program that:
| 69.42 | Increase: 69.42 |
| 100 | Increase: 100.00 |
| END | Total: 174.93 |

[hints]
[hint]
Read data until reaching END. In every iteration, keep track of the money and then print it after the END command.
[/hint]
[hint]
Don't forget to format the result to the second decimal point!
[/hint]
[/hints]

[/task-description]
[tests]
[test open]
Expand Down Expand Up @@ -1283,6 +1330,16 @@ If she did not manage to reach her goal, you have to print out the following mas
| 3000| |
| Going home| |
| 200| |

[hints]
[hint]
Iterate over the number of steps before reaching the end goal, or receiving one of the stop commands.
[/hint]
[hint]
Check if the sum is less or more than the needed goal.
[/hint]
[/hints]

[/task-description]
[tests]
[test open]
Expand Down Expand Up @@ -1535,6 +1592,9 @@ Read from the console:

[hints]
[hint]
First read the number of bottles of detergent.
[/hint]
[hint]
Detergent quantity = 2 \* 750 = 1500 ml.
53 plates are loaded = > 53 \* 5 = 265 ml. 1500 \- 265 = 1235 ml. left
65 plates = > 65 \* 5 = 325 ml 1235 \- 325 = 910 ml. left
Expand Down Expand Up @@ -2010,6 +2070,16 @@ Create a program that calculates the **average grade** of a student for his enti
| 6 | |
| 5.43 | |
| 5 | |

[hints]
[hint]
After reading the name, iterate over the 12 grades.
[/hint]
[hint]
Get their average value, and if it is more than 4.00 print that the students graduates, other wise do not print anything.
[/hint]
[/hints]

[/task-description]
[tests]
[test open]
Expand Down