Starting from:
$30

$24

Lab 01 first Java programs, debugging Solved

Lab Objectives: ​first Java programs, debugging


For all labs in CS 101, your solutions must conform to these ​CS101 style guidelines​(rules!)

Step 1: Organize your H: drive.

    • Organizing your work from the beginning is important. Set up the folder structure on your H: drive according to the instructions found at the following URL (​http://www.cs.bilkent.edu.tr/~adayanik/cs101/practicalwork/defaultFolderSetup.htm​)

Step 2: Practice compiling programs
    • Read and follow ​these instructions​to install and use DrJava.
Step 3: Debugging programs. (part a)

    • Create a project, Lab01a in the Lab01 folder on your H: drive.

    • Download the file ​Lab01a.java and include it in this project. The program does not compile. Find and fix the syntax errors in the program so that it will compile and run. When it runs ​successfully the program will give the output shown. Check your output to ensure it appears correctly.

Sample Run:

Hello everyone, below are some course details

Welcome to CS101 SPRING 2019 Lab 01

There are: 10 lab sessions in this course.

Labs contribute to gradePercent * 25% of your total grade.

This lab
:
2.5
points
All labs
:
25.0
points
Please come prepared...


Good luck!

Step 4: Creating Basic Programs

(part b)

    • Create a new project, ​Lab01b​. Write a program that will determine the daily caloric needs of an individual (basal metabolic rate/bmr). The formula for bmr is:

BMR = 655 + (9.6 x your weight) + (1.8 x your height) - (4.7 x your age)

    • Set the weight / height / age values as in sample run below, and store all values in variables. You should define CONSTANTS to store the multipliers. Remember to give constants / variables meaningful names.

    • Calculate the bmr with the specified values and display it. Also, assuming the same wieght and the same height, by changing the age, recalculate the bmr and display it as shown in the sample run below on the console.

Sample Run: weight(kg): 62 height(cm): 160 age(years): 25

Based on a height of 160 and weight of 62 and age of 25, your BMR is 1420.6999999999998 calories

Next year when you are 26, your bmr will be 1416.0 calories

Last year when you were 24, your bmr was 1425.3999999999999 calories



(part c)

    • Create a new project, ​Lab01c​in the Lab01 folder on your H: drive.
    • Write a Java program to compute the following expression, where a and b are 2 and 3.5 respectively. Define variables to store all values in the expression. Set x value to 4 and 4.5 as in sample runs below. Display the result of f(x) on the console.











Sample Run 1:

x: 4

f(4. ) is 0.9692332344763441

Sample Run 2

x: 4.5

f(4.5) is 0.9928090154076699

More products