IT401

Business Computer Languages

IT 401



Question One

Learning Outcome(s):

- Use programming language elements including syntax, data types, conditional statement, control structures, procedures and arrays in order to create a program based on specification.

- Use Integrated Development Environment (IDE for the editing, building, debugging, and testing of programs.

Write a Java program (code + screenshot of output) that takes a user input temperature and displays an output as follows:

Temperature

Output

temperature > 40

Hot

40 temperature > 25

Warm

25 temperature > 15

Nice

15 temperature

Cold

Sample run1:

Please input the temperature: 45

Hot


Sample run2:

Please input the temperature: 40

Warm


Sample run3:

Please input the temperature: 20

Nice


Sample run4:

Please input the temperature: 5

Cold


Sample run5:

Please input the temperature: -10

Cold


Answer

Question Two

Learning Outcome(s):

- Use programming language elements including syntax, data types, conditional statement, control structures, procedures and arrays in order to create a program based on specification.

- Use Integrated Development Environment (IDE for the editing, building, debugging, and testing of programs.

Write a Java program (code + screenshot of output) that takes a user input temperature and weather and displays an output as follows:

Weather

Temperature

Output

ANY (sunny OR cloudy)

temperature > 40

Stay at home

sunny

40 temperature > 25

Go to the mall

cloudy

Go to the park

sunny

25 temperature > 15

Stay in the shade

cloudy

Have a BBQ party

sunny

15 temperature

Walk under the sun

cloudy

Keep warm

Sample run1:

Please input the weather (sunny OR cloudy): sunny

Please input the temperature: 50

Stay at home


Sample run2:

Please input the weather (sunny OR cloudy): cloudy

Please input the temperature: 50

Stay at home

Sample run3:

Please input the weather (sunny OR cloudy): sunny

Please input the temperature: 40

Go to the mall

Sample run4:

Please input the weather (sunny OR cloudy): cloudy

Please input the temperature: 26

Go to the park

Sample run5:

Please input the weather (sunny OR cloudy): sunny

Please input the temperature: 25

Stay in the shade

Sample run6:

Please input the weather (sunny OR cloudy): cloudy

Please input the temperature: 16

Have a BBQ party

Sample run7:

Please input the weather (sunny OR cloudy): sunny

Please input the temperature: 15

Walk under the sun

Sample run8:

Please input the weather (sunny OR cloudy): cloudy

Please input the temperature: 5

Keep warm

Answer

Question Three

Learning Outcome(s):

- Use programming language elements including syntax, data types, conditional statement, control structures, procedures and arrays in order to create a program based on specification.

- Use Integrated Development Environment (IDE for the editing, building, debugging, and testing of programs.

Convert the following while loop into a for loop.

int count = 0;

int numberOfCaptialLetters = 0;

String text = "Hello There How Are You?";

while(count < text.length()) {

char currentChar = text.charAt(count);

if(Character.isUpperCase(currentChar)) {

numberOfCaptialLetters++;

}

count++;

System.out.println("Total = " + numberOfCaptialLetters);

Answer

Question Four

Learning Outcome(s):

- Use programming language elements including syntax, data types, conditional statement, control structures, procedures and arrays in order to create a program based on specification.

- Use Integrated Development Environment (IDE for the editing, building, debugging, and testing of programs.

Write a Java program (code + screenshot of output) that takes student grades as double values and then outputs the following:

  • The number of inputted grades

  • The average

Sample run1:

Please input student grade or (-1) to stop: 20

Please input student grade or (-1) to stop: 80

Please input student grade or (-1) to stop: 80

Please input student grade or (-1) to stop: -1

The number of student grades: 3

The average is: 60.0

Sample run2:

Please input student grade or (-1) to stop: 50

Please input student grade or (-1) to stop: 100

Please input student grade or (-1) to stop: -1

The number of student grades: 2

The average is: 75.0

Sample run3:

Please input student grade or (-1) to stop: -1

No grades inputted

Answer