Skip to content

Github-Amity/JavaBasics1

Repository files navigation

JavaBasics1

Java Variables, Types, Expressions and User Input

What to know

Before you begin this project, you need to be familiar with Java variables, data types, Strings, arithmetic expressions and reading user input.

If you are not familiar with this already, watch the following tutorials within the given time frame:

It is highly recommended to type and run the code along with the video on any IDE or using an online compiler such as online-java.com.

The Project - BMI Calculator

Write a program that asks the user for their name, height and weight and returns their BMI (Body Mass Index).

Body Mass Index formula:
image

Hint: You can use the Math.pow() function by importing the Math module, by adding import java.util.* line at the beginning of your file.

Instructions

  • Getting the code:

    • If you're using an online compiler: Copy the code from the project file BMICalculator.java and paste it in an online java compiler. Change the class name and its references to "Main" to match the file name of the online compiler (or you can create a new file in the online compiler and name it the same as the file name given here). Watch this tutorial for full comprehension.

    • If you're using a code editor IDE: Download the code (ZIP file). Watch this to learn how to do that.

    • If you have git installed: Clone the repository.

  • There are three blocks of code you need to add. Each block comes with a number (example: // 1️⃣ FIRST) that indicates the order in which you must do the project. Complete the first block before moving on to the second and third. The instructions for the code you need to write are given with 🔴 emoji and the areas are marked with ⬇️⬆️ emojis. Do NOT write anything outside these areas.
  • Once you are done, run the code in your editor and make sure that your method is correct and your input and output match the ones given below.

Input:
image

Output:
image

  • Project Submission:

    • If you're using an online compiler: Simply create a new file, add your filename including your name (eg: SalmaBMICalculator.java) and open a pull request. Watch this to learn how to do that.
    • If you're using a code editor IDE: Before submitting, change the name of the file to include your name. Watch this to learn how to do that. For example:
      If your name is Salma, change the name of the file to SalmaBMICalculator.java
    • Similarly, change the name of your class (and all its references) to include your name (otherwise, the code will not run in your IDE).
    • Then create a fork of this repository, submit your file and open a pull request. Watch this to learn how to do that.

Congratulations on completing the project!

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages