Untitled

public
denzelle.tagupa Nov 20, 2024 Never 25
Clone
Java paste1.java 27 lines (22 loc) | 742 Bytes
1
public class two_D_Arrr {
2
public static void main(String[] args) {
3
String num [][] = new String[3][3];
4
5
//first [] is the x axis or column
6
// second [] is y axis or row
7
num[0][0] = "Axe";
8
num[0][1] = " Shadow Fiend";
9
num[0][2] = " Tiny";
10
num[1][0] = "Sniper";
11
num[1][1] = " Dow Ranger";
12
num[1][2] = " ElderTitan";
13
num[2][0] = "Rubick";
14
num[2][1]= " Bristle Back";
15
num[2][2] = " Jackiro";
16
17
18
for(int i = 0; i < num.length; i++){
19
System.out.println();
20
for(int j = 0; j < num.length; j++) {
21
System.out.print(" "+ num[i][j]);
22
}
23
}
24
25
}
26
27
}
Java paste2.java 20 lines (15 loc) | 505 Bytes
1
import java.util.Scanner;
2
3
public class favmov {
4
public static void main(String[] args) {
5
Scanner sc = new Scanner(System.in);
6
String [] movies = new String[3];
7
8
for(int i = 0; i < 3; i++) {
9
System.out.print("Enter Favorite Movie: ");
10
movies[i] = sc.nextLine();
11
}
12
13
System.out.println("Here are your Fav Movies");
14
for(int i = 0; i < 3; i++) {
15
System.out.println(movies[i]);
16
}
17
18
}
19
20
}
Java paste3.java 39 lines (29 loc) | 1.01 KB
1
import java.util.Scanner;
2
3
public class Sum_of_All2 {
4
public static void main(String[] args) {
5
Scanner sc = new Scanner(System.in);
6
int [] arr = new int[3];
7
char ch;
8
9
10
11
do {
12
13
for(int i = 0 ; i < arr.length; i++) {
14
System.out.print("Enter Number: ");
15
arr[i] = sc.nextInt();
16
}
17
Sumofall(arr);
18
19
System.out.println("Do you want to keep using the program? Y N");
20
ch = sc.next().charAt(0);
21
sc.nextLine();
22
} while (ch == 'y' || ch == 'Y');
23
System.out.println("Thank you for using the program :)");
24
}
25
26
27
public static void Sumofall(int[]arr) {
28
int sum = 0;
29
int av = 0;
30
for(int i = 0; i < arr.length; i++) {
31
sum += arr[i];
32
}
33
34
System.out.println("Heres the sum of all values: "+ sum);
35
av = sum / arr.length;
36
System.out.println("The Average of all values is: " + av);
37
}
38
39
}
Java paste4.java 35 lines (21 loc) | 708 Bytes
1
import java.util.Scanner;
2
3
public class Reverse {
4
5
public static void main(String[] args) {
6
Scanner sc = new Scanner(System.in);
7
int [] num = new int[4];
8
9
lopar(sc, num);
10
rev(num);
11
12
13
}
14
15
public static void lopar (Scanner sc, int [] num) {
16
17
for(int i = 0; i < num.length; i++){
18
System.out.println("Enter Number: ");
19
num[i] = sc.nextInt();
20
21
}
22
23
}
24
25
public static void rev (int [] num) {
26
System.out.println("Reversed: ");
27
for(int i = 3; i >= 0; i --) {
28
System.out.print(" " + num[i]);
29
}
30
}
31
32
33
34
35
}
Java paste5.java 67 lines (52 loc) | 1.87 KB
1
import java.util.Scanner;
2
3
public class voidatm {
4
static double balance = 0;
5
static double deposit = 0;
6
static double withraw = 0;
7
public static void main(String[] args) {
8
Scanner sc = new Scanner(System.in);
9
10
11
while (true) {
12
13
14
ATMmenu(sc);
15
16
}
17
}
18
19
public static void ATMmenu (Scanner sc) {
20
21
System.out.println("ATM Menu");
22
System.out.println("1. View Balance");
23
System.out.println("2. Deposti");
24
System.out.println("3. Withraw");
25
System.out.println("4. Exit");
26
int select = sc.nextInt();
27
transac(select);
28
}
29
30
public static void transac(int select) {
31
Scanner sc = new Scanner(System.in);
32
33
34
switch (select) {
35
case 1:
36
System.out.println("Your Balance is: " + balance);
37
break;
38
39
case 2 :
40
System.out.println("Enter amount deposit: ");
41
deposit = sc.nextDouble();
42
balance += deposit;
43
System.out.println(balance);
44
break;
45
46
case 3 :
47
System.out.println("Enter Amount Withraw: ");
48
withraw = sc.nextDouble();
49
if(balance < withraw) {
50
System.out.println("Insuficient funds");
51
} else {
52
balance -= withraw;
53
System.out.println("You have Withrawed :" + withraw );
54
System.out.println("Heres your new balance: " + balance);
55
}
56
break;
57
case 4 :
58
System.out.println("Thank you for Using the Program : )");
59
System.exit(0);
60
break;
61
default:
62
break;
63
}
64
65
}
66
67
}
Java changingArray 128 lines (84 loc) | 3.73 KB
1
import java.util.Scanner;
2
3
public class changingArray {
4
5
static String[][] heroes = {
6
{"Juggernaut" ,"Anti-Mage ", " Phantom Assasin" },
7
{" Bristle Back " ," Tide Hunter " , " Axe "},
8
{" Sniper " , "Drow Ranger " , " Windrunner "}
9
};
10
public static void main(String[] args) {
11
Scanner sc = new Scanner(System.in);
12
13
14
while(true) {
15
viewArray(heroes, sc);
16
17
}
18
19
20
}
21
22
public static void viewArray (String [][] heroes , Scanner sc) {
23
24
25
26
27
System.out.println("\tTHIS IS A LIST PROGRAM\n");
28
29
int counter = 1;
30
for(int i = 0; i < heroes.length; i++) {
31
System.out.println();
32
33
for(int b = 0; b < heroes.length; b++ ) {
34
System.out.printf("%5d, %s", counter, heroes[i][b].trim());
35
counter++;
36
}
37
}
38
39
System.out.println();
40
System.out.println("\nWhat do you want to do?");
41
System.out.println("1. Replace List Content");
42
System.out.println("2. Exit");
43
44
int selection = sc.nextInt();
45
46
47
rewrite(selection, sc, heroes);
48
49
50
51
52
}
53
54
public static String[][] rewrite (int selection, Scanner sc, String[][]heroes) {
55
56
57
if(selection == 1) {
58
59
60
System.out.println("Enter The Number of the Hero That you want to replace: ");
61
int replace = sc.nextInt();
62
sc.nextLine();
63
switch (replace) {
64
case 1:
65
66
System.out.print("Enter Nameof the New Hero: ");
67
heroes[0][0] = sc.nextLine();
68
return heroes;
69
case 2:
70
System.out.print("Enter Name of the New Hero: ");
71
heroes [0][1] = sc.nextLine();
72
return heroes;
73
74
case 3:
75
System.out.print("Enter Name of the New Hero: ");
76
heroes [0][2] = sc.nextLine();
77
return heroes;
78
79
case 4:
80
System.out.print("Enter Name of the New Hero: ");
81
heroes [1][0] = sc.nextLine();
82
return heroes;
83
84
case 5:
85
System.out.print("Enter Name of the New Hero: ");
86
heroes [1][1] = sc.nextLine();
87
return heroes;
88
89
case 6:
90
System.out.print("Enter Name of the New Hero: ");
91
heroes [1][2] = sc.nextLine();
92
return heroes;
93
94
case 7:
95
System.out.print("Enter Name of the New Hero: ");
96
heroes [2][0] = sc.nextLine();
97
return heroes;
98
99
case 8:
100
System.out.print("Enter Name of the New Hero: ");
101
heroes [2][1] = sc.nextLine();
102
return heroes;
103
104
case 9:
105
System.out.print("Enter Name of the New Hero: ");
106
heroes [2][2] = sc.nextLine();
107
return heroes;
108
109
default:
110
111
return heroes;
112
113
}
114
} else if(selection ==2 ) {
115
System.exit(0);
116
} else {
117
System.out.println("You Entered an Invalid Selection");
118
return heroes;
119
}
120
121
122
return heroes;
123
124
}
125
126
127
128
}