Professional Documents
Culture Documents
import java.util.Scanner;
public class L3Q1 {
while (num != 0) {
total += num;
count++;
if (num > 0) {
positive++;
} else{
negative++;
}
num = input.nextInt();
}
Output
Question 2
import java.util.Scanner;
public class L3Q2 {
System.out.println("Kilograms Pounds");
Output
Question 3
if (year == 10) {
TenYear = tuition;
}
}
Output
Question 4
import java.util.Scanner;
public class L3Q4 {
int highestScore = 0;
String highestScoreName = "";
Output
Question 5
import java.util.Scanner;
public class L3Q5 {
if (i == 0) {
highest = score;
student1 = name;
}
else if (i == 1) {
highest2 = score;
student2 = name;
}
else if (i > 1 && score > highest && score > highest2) {
highest2 = highest;
student2 = student1;
highest = score;
student1 = name;
}
else if (i > 1 && score > highest2) {
student2 = name;
highest2 = score;
}
}
Output
Question 6
if (count % NUMBERS_LINE == 0)
System.out.println(i);
else
System.out.print(i + " ");
}
}
System.out.println();
}
Output
Question 7
do {
balance = commission = 0;
salesAmount += 0.01;
if (salesAmount > 0)
commission += balance * 0.08;
}
}
Output
Question 8import java.util.Scanner;
public class L3Q8 {
Output