exercise3

This commit is contained in:
2024-10-13 21:42:48 +03:00
parent 356330094e
commit 87c609de8c
4 changed files with 37 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,26 @@
import java.util.Scanner;
public class first{
public static void main(String[] args) {
int test1;
int test2;
double radius;
System.out.println("Test Data:");
System.out.println("a. "+(-5 + 8 * 6));
System.out.println("b. "+ ((55+9) % 9));
System.out.println("c. "+ (20 + -3*5 / 8));
System.out.println("d. "+ (5 + 15 / 3 * 2 - 8 % 3));
Scanner scan = new Scanner(System.in);
System.out.println("Enter integer 1");
test1 = scan.nextInt();
System.out.println("Enter integer 2");
test2 = scan.nextInt();
System.out.println("The PRODUCT of two integer: "+ (test1*test2));
System.out.println("Enter radius of a circle! (pi taken as 3!)");
radius = scan.nextDouble();
System.out.println("The area of circle: "+(3*radius*radius)+"\nThe perimeter of circle: "+(2*3*radius));
}
}

Binary file not shown.

View File

@ -0,0 +1,37 @@
import java.util.Scanner;
import java.util.Random;
public class name{
public static void main(String args[]) {
String name1;
String name2;
Scanner scan = new Scanner(System.in);
Random generator = new Random();
int random1 = generator.nextInt(10,99);
System.out.println("Enter your name!");
name1 = scan.nextLine();
System.out.println("Enter your surname!");
name2 = scan.nextLine();
String selectedName1 = name1.substring(1);
String secretName1 = name1.replaceAll(selectedName1,"*");
String selectedName2 = name2.substring(5);
String secretName2 = name2.replaceAll(selectedName2,"*");
System.out.print("First name: "+secretName1+"\tLast Name: "+secretName2+"\tAccount ID: "+random1+"\n");
System.out.print("Phone number:");
int randomfirst = generator.nextInt(8);
int randomsecond = generator.nextInt(8);
int randomthird = generator.nextInt(8);
int random655 = generator.nextInt(556) + 100;
int random1000 = generator.nextInt(9000) + 1000;
System.out.println(""+randomfirst+randomsecond+randomthird+"-"+random655+"-"+random1000);
String original = "This is an original example string";
String change = original.replace("e", "j");
System.out.println("Original: "+original);
System.out.println("Change: "+change);
}
}