Skip to content

Commit 252aed1

Browse files
Update chapter-02-simple-calculations.md
Review up to "Exercise: Greeting by name"
1 parent 99e8da5 commit 252aed1

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

chapter-02-simple-calculations.md

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -504,63 +504,63 @@ Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/649#0
504504

505505
### Exercise: Inches to centimeters
506506

507-
Write a program that **reads a number from the console** (not necessarily an integer) and converts the number from **inches to centimeters.** For this purpose **it multiplies the inches by 2.54** (because one inch = 2.54 centimeters).
507+
Write a program that **reads a number from the console** (not necessarily an integer) and converts the number from **inches to centimeters.** For this purpose **multiply the inches by 2.54** (because one inch = 2.54 centimeters).
508508

509-
#### Hints and Guidelines
509+
#### Hints and guidelines
510510

511-
First, we create **new Java class** in the project “SimpleCalculations”. We click on the folder **src** and choose [**New**][**Java Class**]:
511+
First, we create a **new Java class** in the project “SimpleCalculations”. We click on the folder **src** and choose [**New**][**Java Class**]:
512512

513513
![](assets/chapter-2-1-images/08.Inches-to-centimeters-01.png)
514514

515-
A dialogue window shows up in which we write file’s name. In our case this is "InchesToCentimeters" → [**OK**]:
515+
A dialogue window appears in which we write the file’s name. In our case this is "InchesToCentimeters" → [**OK**]:
516516

517517
![](assets/chapter-2-1-images/08.Inches-to-centimeters-02.png)
518518

519519
Next, we have to write the **program code**:
520520

521521
![](assets/chapter-2-1-images/08.Inches-to-centimeters-03.png)
522522

523-
**We start the program** with the right button of the mouse on the window of the current program. We choose [**Run InchesToCentim...main()**] or we press [**Ctrl+Shift+F10**]. This shortcut starts the program in the current Java class (the one in which we wrote last):
523+
**We start the program** with the right click on the window of the current program. We choose [**Run InchesToCentim...main()**] or we press [**Ctrl+Shift+F10**]. This shortcut starts the program in the current Java class (the one in which we wrote last):
524524

525525
![](assets/chapter-2-1-images/08.Inches-to-centimeters-04.png)
526526

527527
We obtain the following result:
528528

529529
![](assets/chapter-2-1-images/08.Inches-to-centimeters-05.png)
530530

531-
Now **let's switch to the previous program / task** ("Square Area"). This is done by double-clicking on the file **`SquareArea.java`** from the folder **src** in the project [**SimpleCalculations**]:
531+
Now **let's switch to the previous program/task** ("Square Area"). This is done by double-clicking on the file **`SquareArea.java`** from the folder **src** in the project [**SimpleCalculations**]:
532532

533533
![](assets/chapter-2-1-images/08.Inches-to-centimeters-06.png)
534534

535535
If we use [**Shift+F10**] or press one of the two green arrows (located at the top right and bottom left of the IntelliJ IDEA window)
536536

537537
![](assets/chapter-2-1-images/08.Inches-to-centimeters-07.png)
538538

539-
The last compiled program will be executed (**InchesToCentimeters**). We can see it as a name in the upper right corner of the window in front of one of the two green arrows:
539+
the last compiled program will be executed (**InchesToCentimeters**). We can see it as a name in the upper right corner of the window in front of one of the two green arrows:
540540

541541
![](assets/chapter-2-1-images/08.Inches-to-centimeters-08.png)
542542

543-
**Switching between projects** is very easy, isn't it? Just choose the file with the source code of the program, double click it and when it starts, the program from the current file is being executed.
543+
**Switching between projects** is an easy task, isn't it? Choose the file with the source code of the program, double click on it and when it starts, the program from the current file runs.
544544

545-
Let's test with floating-point numbers, for example with **2.5**:
545+
Let's test with floating-point numbers, for example, with **2.5**:
546546

547547
![](assets/chapter-2-1-images/08.Inches-to-centimeters-09.png)
548548

549549
<table><tr><td><img src="/assets/alert-icon.png" style="max-width:50px" /></td>
550-
<td>В зависимост от регионалните настройки на операционната система, е възможно вместо <b>десетична точка</b> (US настройки) да се използва <b>десетична запетая</b> (BG настройки).</td>
550+
<td>Depending on the regional settings of the operating system, it is possible to use <b> decimal point </b> (US settings) instead of <b> decimal comma </b> (BG settings).</td>
551551
</tr></table>
552552

553553
If the program expects a decimal point and instead you enter a number with a decimal comma or the opposite (to enter a decimal point, when a decimal comma is expected), the following error will be produced:
554554

555555
![](assets/chapter-2-1-images/08.Inches-to-centimeters-10.png)
556556

557-
It is recommended to **change the settings of your computer**, in order to use a **decimal point**:
557+
It is recommended to **change the settings of your computer**, to use a **decimal point**:
558558

559559
![](assets/chapter-2-1-images/08.Inches-to-centimeters-11.png)
560560

561561
![](assets/chapter-2-1-images/08.Inches-to-centimeters-12.png)
562562

563-
#### Testing in the Judge System
563+
#### Testing in the Judge system
564564

565565
Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/649#1](https://judge.softuni.bg/Contests/Practice/Index/649#1).
566566

@@ -569,13 +569,13 @@ The solution should be accepted as a completely correct one:
569569
![](assets/chapter-2-1-images/08.Inches-to-centimeters-13.png)
570570

571571

572-
### Problem: Greeting by Name
572+
### Exercise: Greeting by name
573573

574574
Write a program that **reads from the console a person's name** and prints **`Hello, <name>!`**, where **`<name>`** is the name entered earlier.
575575

576-
#### Hints and Guidelines
576+
#### Hints and guidelines
577577

578-
First, we create **new Java class** with name “Greeting” in the project “SimpleCalculations”:
578+
First, we create a **new Java class** with the name “Greeting” in the project “SimpleCalculations”:
579579

580580
![](assets/chapter-2-1-images/09.Greeting-by-name-01.png)
581581

@@ -587,16 +587,16 @@ First, we create **new Java class** with name “Greeting” in the project “S
587587

588588
![](assets/chapter-2-1-images/09.Greeting-by-name-03.png)
589589

590-
#### Testing in the Judge System
590+
#### Testing in the Judge system
591591

592592
Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/649#2](hhttps://judge.softuni.bg/Contests/Practice/Index/649#2).
593593

594594

595-
### Problem: Concatenating Text and Numbers
595+
### Exercise: Concatenating Text and Numbers
596596

597597
Write a Java program, that reads from the console a first name, last name, age and city and prints a message of the following kind: **`You are <firstName> <lastName>, a <age>-years old person from <town>.`**.
598598

599-
#### Hints and Guidelines
599+
#### Hints and guidelines
600600

601601
We add to the existing IntelliJ IDEA Project one more Java Class with name "`ConcatenateData`". **We write the code**, which reads the input from the console:
602602

@@ -610,20 +610,20 @@ In the picture above the code is blurred on purpose, in order for you to think o
610610

611611
СNext, the solution should be tested locally using [**Ctrl+Shift+F10**] and by entering an exemplary input data.
612612

613-
#### Testing in the Judge System
613+
#### Testing in the Judge system
614614

615615
Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/649#3](https://judge.softuni.bg/Contests/Practice/Index/649#3).
616616

617617

618-
### Problem: Trapezoid Area
618+
### Exercise: Trapezoid Area
619619

620620
Write a program that reads three numbers from the console **b1**, **b2** and **h** and calculates **the area of a trapezoid** with bases **b1** and **b2** and height **h**. The formula for trapezoid area is **(b1 + b2) * h / 2**.
621621

622622
On the figure below shows a trapezoid with bases 8 and 13 and height 7. It has an area **(8 + 13) * 7 / 2 = 73.5**.
623623

624624
![](assets/chapter-2-1-images/11.Trapezoid-area-01.png)
625625

626-
#### Hints and Guidelines
626+
#### Hints and guidelines
627627

628628
Again, we have to add to the existing IntelliJ IDEA Project another **Java class** with name "`TrapezoidArea`" and to write **the code that reads the input from the console, calculates the trapezoid area and prints it**:
629629

@@ -633,57 +633,57 @@ The code on the picture is purposely blurred, in order for you to give it a thou
633633

634634
**Test** your solution locally using [**Ctrl+Shift+F10**] and enter an exemplary data.
635635

636-
#### Testing in the Judge System
636+
#### Testing in the Judge system
637637

638638
Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/649#4](https://judge.softuni.bg/Contests/Practice/Index/649#4).
639639

640640

641-
### Problem: Circle Area and Perimeter
641+
### Exercise: Circle Area and Perimeter
642642

643643
Write a program that reads from the console **a number r** r and calculates and prints **the area and perimeter of the circle**/**round** with **radius r**.
644644

645-
#### Sample Input and Output
645+
#### Sample input and output
646646

647647
| Input | Output |
648648
|-----|--------------------------------------------------------|
649649
| 3 | Area = 28.2743338823081 <br> Perimeter = 18.8495559215388|
650650
| 4.5 | Area = 63.6172512351933 <br> Perimeter = 28.2743338823081|
651651

652-
#### Hints and Guidelines
652+
#### Hints and guidelines
653653

654654
For the calculations you may use the following formulas:
655655
- **`Area = Math.PI * r * r`**.
656656
- **`Perimeter = 2 * Math.PI * r`**.
657657

658-
#### Testing in the Judge System
658+
#### Testing in the Judge system
659659

660660
Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/649#5](https://judge.softuni.bg/Contests/Practice/Index/649#5).
661661

662662

663-
### Problem: Rectangle Area
663+
### Exercise: Rectangle Area
664664

665665
**A rectangle** is defined by the **coordinates** at two of its opposite angles (x1, y1) – (x2, y2). Calculate its **area and perimeter**. **The input** is read from the console. The numbers **x1, y1, x2 и y2** are given one per line. **The output** is printed on the console and it has to contain two lines, each with one number – the area and the perimeter.
666666

667667
![](/assets/chapter-2-1-images/12.Rectangle-area-01.png)
668668

669-
#### Sample Input and Output
669+
#### Sample input and output
670670

671671
| Input | Output |
672672
|-----------------------------------------|-------------------|
673673
|60<br>20<br>10<br>50 |1500<br>160 |
674674
|30<br>40<br>70<br>-10 |2000<br>180 |
675675
|600.25<br>500.75<br>100.50<br>-200.5 |350449.6875<br>2402 |
676676

677-
#### Testing in the Judge System
677+
#### Testing in the Judge system
678678

679679
Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/649#6](https://judge.softuni.bg/Contests/Practice/Index/649#6).
680680

681681

682-
### Problem: Triangle Area
682+
### Exercise: Triangle Area
683683

684684
Write a program that reads from the console **a side and height of a triangle** and calculates its area. Use **the formula** for triangle area: **area = a * h / 2**. Round the result to **2 digits after the decimal point using `Math.round(area, 2)`**.
685685

686-
#### Sample Input and Output
686+
#### Sample input and output
687687

688688
| Input | Output |
689689
|--------------------|---------------------|
@@ -692,16 +692,16 @@ Write a program that reads from the console **a side and height of a triangle**
692692
| 7.75 <br>8.45 | Triangle area = 32.74 |
693693
| 1.23456 <br>4.56789 | Triangle area = 2.82 |
694694

695-
#### Testing in the Judge System
695+
#### Testing in the Judge system
696696

697697
Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/649#7](https://judge.softuni.bg/Contests/Practice/Index/649#7).
698698

699699

700-
### Problem: Converter – from °C Degrees to °F Degrees
700+
### Exercise: Converter – from °C Degrees to °F Degrees
701701

702702
Write a program that reads **degrees on Celsius scale** (°C) and converts them to **degrees on Fahrenheit scale** (°F). Look on the Internet for a proper [formula](http://bfy.tw/3rGh "Търсене в Google"), to do the calculations. Round the result to **2 digits after the decimal point**. Here are a few examples:
703703

704-
#### Sample Input and Output
704+
#### Sample input and output
705705

706706
| Input | Output |
707707
|----|-----|
@@ -710,16 +710,16 @@ Write a program that reads **degrees on Celsius scale** (°C) and converts them
710710
| -5.5 | 22.1 |
711711
| 32.3 | 90.14 |
712712

713-
#### Testing in the Judge System
713+
#### Testing in the Judge system
714714

715715
Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/649#8](https://judge.softuni.bg/Contests/Practice/Index/649#8).
716716

717717

718-
### Problem: Converter – from Radians to Degrees
718+
### Exercise: Converter – from Radians to Degrees
719719

720720
Write a program, that reads **ъan angle in [radians](https://bg.wikipedia.org/wiki/Радиан)** (**`rad`**) and converts it to **[degrees](https://bg.wikipedia.org/wiki/Градус_(ъгъл))** (`deg`). Look for a proper formula on the Internet. The number **π** in Java programs is available through **``Math.PI``**. Round the result to the nearest integer using the method **``Math.round(…)``**.
721721

722-
#### Sample Input and Output
722+
#### Sample input and output
723723

724724
| Input | Output |
725725
|------|-----|
@@ -728,29 +728,29 @@ Write a program, that reads **ъan angle in [radians](https://bg.wikipedia.org/w
728728
| 0.7854 | 45 |
729729
| 0.5236 | 30 |
730730

731-
#### Testing in the Judge System
731+
#### Testing in the Judge system
732732

733733
Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/649#9](https://judge.softuni.bg/Contests/Practice/Index/649#9).
734734

735735

736-
### Problem: Converter – USD to BGN
736+
### Exercise: Converter – USD to BGN
737737

738738
Write a program for **conversion of US dollars** (USD) **into Bulgarian levs** (BGN). **Round** the result **2 digits** след десетичния знак. after the decimal point. Use a fixed rate between a dollar and levs: **1 USD = 1.79549 BGN**.
739739

740-
#### Sample Input and Output
740+
#### Sample input and output
741741

742742
| Input | Output |
743743
|------|---------|
744744
| 20 | 35.91 BGN |
745745
| 100 | 179.55 BGN|
746746
| 12.5 | 22.44 BGN |
747747

748-
#### Testing in the Judge System
748+
#### Testing in the Judge system
749749

750750
Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/649#10](https://judge.softuni.bg/Contests/Practice/Index/649#10).
751751

752752

753-
### Problem: \* Currency Converter
753+
### Exercise: \* Currency Converter
754754

755755
Write a program for **conversion of money from one currency into another**. It has to support the following currencies: **BGN, USD, EUR, GBP**. Use the following fixed currency rates:
756756

@@ -760,7 +760,7 @@ Write a program for **conversion of money from one currency into another**. It h
760760

761761
**The input** is **sum for conversion**, **input currency** and **output currency**. **The output** is one number – the converted value of the above currency rates, rounded **2 digits** after the decimal point.
762762

763-
#### Sample Input and Output
763+
#### Sample input and output
764764

765765
| Input | Input |
766766
|------------------|--------|
@@ -769,16 +769,16 @@ Write a program for **conversion of money from one currency into another**. It h
769769
| 12.35<br>EUR<br>GBP| 9.53 GBP |
770770
|150.35<br>USD<br>EUR|138.02 EUR|
771771

772-
#### Testing in the Judge System
772+
#### Testing in the Judge system
773773

774774
Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/649#11](https://judge.softuni.bg/Contests/Practice/Index/649#11).
775775

776776

777-
### Problem: ** Date Calculations – 1000 Days on the Earth
777+
### Exercise: ** Date Calculations – 1000 Days on the Earth
778778

779779
Write a program that enters a **birth date** in format **`dd-MM-yyyy`** and calculates the date on which **1000 days** are turned since this birth date and prints it in the same format.
780780

781-
#### Sample Input and Output
781+
#### Sample input and output
782782

783783
| Input | Output |
784784
|--------|--------|
@@ -788,10 +788,10 @@ Write a program that enters a **birth date** in format **`dd-MM-yyyy`** and calc
788788
|01-01-2012|27-09-2014|
789789
|14-06-1980|11-03-1983|
790790

791-
#### Hints and Guidelines
791+
#### Hints and guidelines
792792
* Look for information about the data type **`Date`**, **`Calendar`** and **`SimpleDateFormat`** in Java and in particular look at the methods **`Calendar.setTime(date)`**, **`Calendar.add(countDays)`** and **`SimpleDateFormat.format(date)`**. With their help you can solve the problem without the need to calculate days, months and leap years.
793793
* **Don't print** anything additional on the console except for the wanted date!
794794

795-
#### Testing in the Judge System
795+
#### Testing in the Judge system
796796

797797
Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/649#12](https://judge.softuni.bg/Contests/Practice/Index/649#12).

0 commit comments

Comments
 (0)