Professional Documents
Culture Documents
NIM : 1202210317
SI-45-09
Practices 1 :
Task :
Practices 2 :
Task 1 :
Task 2 :
}
}
Practice 3 :
Task :
import java.util.Scanner;
class games {
public static void main(String[] args) throws Exception {
try (// import java.util.Scanner;
Scanner input = new Scanner(System.in)) {
System.out.print("Enter name: ");
String codename = input.nextLine();
System.out.print("Enter location: ");
String location = input.nextLine();
System.out.print("Enter day: ");
String day = input.nextLine();
System.out.print("Enter mission: ");
String mission = input.nextLine();
System.out.print("Enter number: ");
int number = input.nextInt();
System.out.print("Enter coordinate: ");
double coordinate = input.nextDouble();
if (mission.length() <= 10 ) {
System.out.println("mission must be more 10 inputs");
}
if (mission.length() >= 10 ) {
System.out.println("the ministry of internal affair has appointed you
"+ number +" codename " + codename + " to infiltrate the " + location + " located
at southern part from the zone of alienation");
System.out.println("you will be deployed at coordinate "+ coordinate
+ " with any nesecities for " + day +" days" );
System.out.println("your mission is to " + mission +" i hope you
goodluck agent");
}
}
}
}
Practice 4 :
Task 1 :
import java.util.Scanner;
public class Practice4 {
public static void main(String[]args){
convertFToC();
import java.util.Scanner;
class name {
public static void main(String[] args) throws Exception {
Scanner scan = new Scanner ( System.in);
System.out.println(" Enter Name : ");
String name = scan.nextLine();
System.out.println("Input: " + name);
System.out.println("Formated: " + formatName(name));
}
Task 1 :
import java.util.Scanner;
class task2 {
public static void main(String[] args) {
System.out.print("Enter a color code : ");
Scanner myObj = new Scanner(System.in);
int color = myObj.nextInt();
if (color >= 380 && color <= 450 ) {
System.out.print("violet");
}
if (color >= 450 && color <= 495 ) {
System.out.print("blue");
}
if (color >= 495 && color <= 570 ) {
System.out.print("Green");
}
if (color >= 570 && color <= 590 ) {
System.out.print("Yellow");
}
if (color >= 590 && color <= 620 ) {
System.out.print("Orange");
}
if (color >= 620 && color <= 750 ) {
System.out.print("Red");
}
else {
System.out.print("The entered wavelength is not a part of the visible
spectrum");
}
}
}
Task 2 :
import java.util.Scanner;
class traffic {
public static void main(String[] args) {
System.out.print("Enter a color code : ");
Scanner myObj = new Scanner(System.in);
int color = myObj.nextInt();
if (color == 1 ) {
System.out.print("Next Traffic Light is green");
}
if (color == 2 ) {
System.out.print("Next Traffic Light is yellow");
}
if (color == 3 ) {
System.out.print("Next Traffic Light is red");
}
if (color <= 1) {
System.out.print("Invalid color");
}
if (color >= 3) {
System.out.print("Invalid color");
}
}
}