Professional Documents
Culture Documents
Java Practice Problems
Java Practice Problems
TAREGA
BSIT-2C
ACTIVITY NO.1 – JAVA PRACTICE PROBLEMS
1.PNG
package act_ouputs;
import java.util.Scanner;
num1 = output.nextInt();
num2 = output.nextInt();
} else {
}
2.PNG
package act_ouputs;
import java.util.Scanner;
String name;
name = output.nextLine();
math = output.nextInt();
science = output.nextInt();
history = output.nextInt();
ss = output.nextInt();
float pt = (float)sum/4;
System.out.println("Percentage: "+pt);
if(pt < 75){
System.out.println("Status: Failed\n");
}else{
System.out.println("Status: Passed\n");
System.out.println("Congrats "+name);
3.PNG
package act_ouputs;
import java.util.Scanner;
String name;
quan = output.nextInt();
price = output.nextInt();
System.out.println("Number of sold products: ");
sold = output.nextInt();
still = output.nextInt();
total = sold*price;
loss = quan-sold;
loss1 = (loss-still)*price;
profit = quan*price;
4.PNG
package act_ouputs;
import java.util.Scanner;
fname = output.nextLine();
lname = output.nextLine();
year = output.nextInt();
}else{
5.SLIDE2.PNG
package act_ouputs;
import java.util.Scanner;
public class Act_Ouputs {
int year;
fname = output.nextLine();
lname = output.nextLine();
year = output.nextInt();
6.SLIDE3.PNG
package act_ouputs;
import java.util.Scanner;
public class Act_Ouputs {
height = output.nextInt();
width = output.nextInt();
7.SLIDE4.PNG
package act_ouputs;
import java.util.Scanner;
public class Act_Ouputs {
mins = output.nextInt();
hr = mins/60;
min = mins%60;