0% found this document useful (0 votes)
17 views

Backend Assignment (2)

The document outlines a week 2 assessment consisting of three programming activities. Activity 1 requires creating a program to calculate bridge tolls based on dice rolls, Activity 2 involves a number guessing game with user feedback, and Activity 3 asks for the sum of all natural numbers below 100 that are multiples of 3 or 5. Each activity includes specific input and output requirements.

Uploaded by

ettolrahcava
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Backend Assignment (2)

The document outlines a week 2 assessment consisting of three programming activities. Activity 1 requires creating a program to calculate bridge tolls based on dice rolls, Activity 2 involves a number guessing game with user feedback, and Activity 3 asks for the sum of all natural numbers below 100 that are multiples of 3 or 5. Each activity includes specific input and output requirements.

Uploaded by

ettolrahcava
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Week 2 Assessment:

Activity 1:

You arrive in front of a bridge that you must cross to reach a village before
dark. Crossing the bridge is not free - the bridgekeeper asks you to roll two
dice to determine the cost.

You decide to write a program to verify that he is charging the right price.

Your program should read two integers, between 1 and 6, representing the
values of each die. If the sum is greater than or equal to 10, then you must
pay a special fee (36 coins). Otherwise, you pay twice the sum of the values
of the two dice. Your program must then display the text "Special tax" or
"Regular tax" followed by the amount you have to pay on the next line.

EXAMPLE

INPUT

OUTPUT

Special tax

36

INPUT

OUTPUT

Regular tax

14
Activity 2:

Write a program that will give a user the opportunity to guess a number that
will be generated randomly. If the guess of the user is too high, it should
display, "guess too high. Try again", if the guess of the user is too low, it
should display "guess too low. Try again". And when the user successfully
guesses correctly. It should display, "Your guess was correct after n
attempts".

Where n is the number of attempts the user made and then finally the
program should stop.

Activity 3:

If we list all the natural numbers below 10 that are multiples of 3 or 5, we


get 3, 5, 6 and 9. The sum of these multiples is 23.

Find the sum of all the multiples of 3 or 5 below 100.

If you have any questions, please ask. But digest the assignment properly before
asking.

You might also like