Postingan

Informatics - BMI Calculator (Week 20)

Gambar
 Do you ever wonder if you're underweight or overweight, but you don't know how to calculate your BMI ( Body Mass Index). Body Mass Index (BMI) is a simple calculation used to determine if a person has a healthy body weight based on their height and weight. A BMI Calculator program is a simple program that calculates a person's Body Mass Index (BMI) based on their weight and height. It categorizes the BMI result into different health ranges such as Underweight, Normal weight, Overweight, or Obese based on standard BMI classifications.  Here's the code of BMI Calculator program! //program BMICalculator.cpp #include <iostream> #include <iomanip> #include <cmath> using namespace std; float weight, height_cm, height_m, bmi; void calculateBMI (){     height_m = height_cm / 100.0;     bmi = weight / (height_m * height_m);     cout << fixed << setprecision(1);     cout << "Your BMI score is " << bm...

Informatics - Addition & Substraction (Week 19)

Gambar
Hola! Como estas? In this blog I will show you a really simple code about addition and subtraction between two numbers. It's really simple and I'm sure every new programmer can do this! Here's the code! // Program: AdditionSubtraction.cpp #include <iostream> using namespace std; int val1, val2; void add() {     cout << "Enter first number: ";     cin >> val1;     cout << "Enter second number: ";     cin >> val2;     int result = val1 + val2;     cout << val1 << " plus " << val2 << " is: " << result << endl; } void subs() {     cout << "Enter first number: ";     cin >> val1;     cout << "Enter second number: ";     cin >> val2;     int result = val1 - val2;     cout << val1 << " minus " << val2 << " is: " << result << endl; } int main() {  ...

Informatics - Triangles (week 18)

 Hi everyone! In this week I just want to show you some codes of how to make a standing up and also upside-down triangle. There will be some types of triangles here so stay tuned! 1. Right Triangle #include <iostream> int main (){     for (int i = 1; i <= 5; i++){         for (int j = 1; j <= i; j++){             std :: cout << "*";         }         std :: cout << std :: endl;     }     return 0; } This program prints a right-angled triangle pattern using asterisks (*). It uses a nested for loop, where the outer loop controls the number of rows (from 1 to 5), and the inner loop controls how many * are printed in each row. In each iteration of the outer loop, the inner loop runs from 1 up to the current row number (i), printing that many stars. After the inner loop finishes, a newline (endl) is printed to move to the next row. As a result, ...

Informatics - Currency Change Calc Version 2 (Week 17)

Gambar
 Hello! How was your holiday? Have you gone to the country that you want? I'm back with Currency Change Calc Version 2!  Don't worry! I only add some addition here but not changing the main code. Here, I only add the do-while loop. A do-while loop is a type of loop that always runs at least once, regardless of the condition. It first executes the code inside the loop, then checks if the condition is true. If it is, the loop repeats; if not, it stops. This is useful in situations where you need to ensure that something happens at least once, such as prompting a user for input until they enter a valid value. Here's the code after some adjustment! //program lengthConverter.cpp #include <iostream> #include <iomanip> #include <limits> using namespace std; double rupiah, won; void rupiah2won(){     do {     cout << "Enter money in rupiah:";     cin >> rupiah;     if (rupiah < 0) {       ...

Informatics - Currency Change Calc Version 1 (Week 16)

Gambar
 OMG It's holiday time! Happy holiday everyone!  Anyway, are you planning to go somewhere on this holiday? Is there any of you who wants to go to outside of the country but still confused about the budget there because you don't know how to calculate currency change? No need to worry! I'm here to help you. So the base of the code will be the same as the length converter which we're going to use functions and switch statement. In this program I will convert Rupiahs to Won and otherwise. So, the first thing you need to find is the currency change. You can find it on google! So here 1 Rupiah is equal to 0.089 Won and 1 Won is equal to 11.26 Rupiahs.  Here's the code of the program! //program CurrencyChangeCalc.cpp #include <iostream> using namespace std; double rupiah, won; void rupiah2won(){     cout << "Enter money in rupiah:";     cin >> rupiah;     won = rupiah*0.089;     cout << rupiah << " rupiah is ...

Informatics - Length Converter Version 2 (Week 15)

Hmm last week we made a length converter from feet to meters and otherwise. Now, I'll show you how to convert centimeters to inch. But here, there will be some addition rather just to change the code. The addition is we will make a do-while loop. In this program, the do-while loop is used to keep asking for input and performing the conversion. If the user enters a negative number, it prints "error" and stops with a break. Here's the code of the centimeters to inch length converter: //program ConverCm2Inch.cpp #include <iostream> #include <iomanip> #include <limits> using namespace std; double cm, inch; void cm2inch(){     do{ cout << "Enter value in cm: "; cin >> cm; if (cm < 0){     cout << "ERROR";     break; } inch = cm * 2.5; cout << cm << "is equal to: " << inch << "inch"; }while (cm < 0); } void inch2cm (){     do { cout << "Enter value in inch: ...

Informatics - Length Converter Version 1 (Week 14)

Gambar
 Hi! Are you working as an architect? Or are you a carpenter? Well, you're on the right page. Have you ever felt the feelings when you need to convert length, but you are too busy to convert it by yourself? Here, I'll show you a code to convert a length from feet to meters and otherwise. You only need an online compiler and a code! Here we'll use functions and switch-case statement to make the length converter. Functions are used in the program to keep the code organized, reusable, and easy to maintain. Instead of writing the conversion logic multiple times, functions allow the program to call them whenever needed, making updates or fixes simpler. The switch-case statement is used because it efficiently handles multiple choices, making the code faster and easier to read compared to multiple if-else statements. Each case corresponds to a specific action, ensuring the correct function is executed based on user input. Here's the code of the program: //program lengthConvert...