Hello SoftUni - Problems Description
Hello SoftUni - Problems Description
Problems for in-class and homework exercises for the course "Programming Basics" @ SoftUni.
Test your solutions in the online judge system: https://judge.softuni.org/Contests/Compete/Index/3487
Next, select the folder as your workspace, to add the JavaScript solution files of your tasks to it.
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
2. The content of the new file will open in the window on the right.
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
4. Run the program with Ctrl + F5. To get the result we need to "call" the function:
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
function nums1To10 () {
// Your code goes here
}
2. Write 10 commands console.log(), one after another, to print the numbers from 1 to 10.
3. Run the program with Ctrl + F5. To get the result you need to "call" the function.
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
4. Inches to Centimeters
Write a function inchesToCm(inch) that reads a floating-point number from the console and converts it
from inches to centimeters.
To do this, multiply the inches by 2.54 (1 inch = 2.54 centimeters).
Attention: depending on the regional settings of the operating system, it is possible to use a decimal comma
instead of a decimal point (US settings). If the program expects a decimal point and enters a number with a
decimal comma or vice versa (a decimal point is entered when a decimal comma is expected), it will not be able
to be executed.
It is recommended that you change the settings on your computer to use a decimal point:
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Create the variable name and save in it the name that is passed from (input).
Display the output on the console using the following template:
How does the example work? The console.log () method allows us to write in parentheses a series of characters
that hold the value of a variable - ${name} and print it on the console.
Note that for this to work, the text must be enclosed by the ` symbol, which recognizes plain text and a variable.
To recognize a variable as such, it must begin with the symbol $ and be enclosed in curly braces: { }.
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
5. Test your solution in judge, without including the calling of the function.
6. Concatenate Data
Write a function concatenateData(firstName, lastName, age, town) and print a message of the
following type:
"You are <firstName> <lastName>, a <age>-years old person from <town>."
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Input Data
The function receives 2 arguments:
1. Name of the architect - text
2. Number of projects to complete – an integer in the range [0 … 100]
Output Data
On the console is printed:
"The architect {name of architect} will need {numbers of hour needed} hours to
complete {number of projects} project/s."
8. Pet Shop
Write a function calculate(dogPackages, catPackages) that calculates the costs needed to buy
food for dogs and cats. The food is bought from a pet shop, a packet of dog food costs 2.50 USD and a packet of
cat food costs 4 USD.
Input Data
The function receives 2 arguments:
1. Number of dog food packages – an integer in the range [0… 100]
2. Number of cat food packages – an integer in the range [0… 100]
Output Data
On the console is printed:
"{final amount} USD."
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
9. Yard Greening
Betty has several houses on the Mediterranean Sea coast and wants to green the yards of some of them, thus
creating a cozy atmosphere and comfort for its guests. She has hired a company for this purpose.
Write a function calculate(meters) that calculates the amount needed that Betty will have to pay to
the project contractor. The price per square meter is 7.61 USD including VAT. Because her yard is quite large,
the contractor company offers an 18% discount on the final price.
Input Data
The function receives only 1 argument:
1. Square meters to be landscaped – a floating-point number in the range [0.00 … 10000.00]
Output Data
Two lines are printed on the console:
"The final price is: {final service price} USD."
"The discount is: {discount} USD."
calculate(550) The final price is: We calculate the cost of landscaping the entire yard:
3432.11 USD.
550 * 7.61 = 4185.50 USD.
The discount is: 753.39
USD. We deduct the discount (18% = 0.18) from the total
amount:
0.18 * 4185.5 = 753.39 USD.
We calculate the final price of the service:
4185.50 – 753.39 3432.11 USD.
calculate(150) The final price is: We calculate the cost of landscaping the entire yard:
936.03 USD.
150 * 7.61 = 1141.50 USD.
The discount is: 205.47
USD. We deduct the discount (18% = 0.18) from the total
amount:
0.18 * 1141.50 = 205.47 USD.
We calculate the final price of the service:
1141.50 – 205.47 936.03 USD.
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.