-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab7.java
More file actions
190 lines (112 loc) · 4.66 KB
/
Copy pathLab7.java
File metadata and controls
190 lines (112 loc) · 4.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
// Programs to be completed This Week and to be submitted in Google Classroom on or before 13/11/2024 @11:30PM
// Write a Java program to create a character array containing the contents of a String
// // Write a Java program to create a character array containing the contents of a String
// public class Main {
// public static void main(String[] args) {
// String str = "Hello, World!";
// char[] charArray = str.toCharArray();
// System.out.println("Character Array: ");
// for (char c : charArray) {
// System.out.print(c + " ");
// }
// }
// }
// Write a Java program to check whether a given string starts with the contents of another string
// // checl wether string startw ith another string
// public class Main{
// public static void main(String[] args) {
// String str1 = "tanmay garwal";
// String str2 = "Hello";
// if (str1.startsWith(str2)) {
// System.out.println("yes");
// } else {
// System.out.println("no");
// }
// }
// }
// Write a Java program to concatenate Two strings
// public class Main{
// public static void main(String[] args) {
// String str1 = "tan";
// String str2 = " may";
// // Concatenate two strings
// String result = str1.concat(str2);
// // Print the result
// System.out.println("Concatenated String: " + result);
// }
// }
// Write a Java program to get the character at the given index within the String
// public class Main{
// public static void main(String[] args) {
// String str = "Tanmay";
// int index = 3;
// char ch = str.charAt(index);
// System.out.println("Character at index " + index + ": " + ch);
// }
// }
// Write a Java program to get the character (Unicode code point) at the given index within the String
// public class Main{
// public static void main(String[] args) {
// String str = "Tanmay";
// int index = 1;
// int unicode = str.codePointAt(index);
// System.out.println("Unicode code point at index " + index + ": " + unicode);
// }
// }
// Work on String Methods discussed in the class.
// In the following program, called ComputeResult, what is the value of result after each numbered line executes(Line no 7 to13)?
// public class ComputeResult {
// public static void main(String[] args) {
// String original = "software";
// StringBuffer result = new StringBuffer("hi");
// int index = original.indexOf('a');
// result.setCharAt(0, original.charAt(0));
// result.setCharAt(1, original.charAt(original.length()-1));
// result.insert(1, original.charAt(4));
// result.append(original.substring(1,4));
// result.insert(3, (original.substring(index, index+2) + " "));
// System.out.println(result);
// }
// }
// Si
// Se
// Sweoft
// Sword t
// Show two ways to concatenate the following two strings together to get the string
// "Hi, mom.":
// String hi = "Hi, ";
// String mom = "mom.";
// public class Main{
// public static void main(String[] args) {
// String hi = "Hi, ";
// String mom = "mom.";
// String result = hi.concat(mom)
// System.out.println(result);
// }
// }
// public class Main{
// public static void main(String[] args) {
// String hi = "Hi, ";
// String mom = "mom.";
// String result = hi + mom;
// System.out.println(result);
// }
// }
// Write a program that computes your initials from your full name and displays them.
// import java.util.Scanner;
// public class Main {
// public static void main(String[] args) {
// Scanner scanner = new Scanner(System.in);
// System.out.print("Enter your full name: ");
// String fullName = scanner.nextLine();
// String[] nameParts = fullName.split(" ");
// String initials = "";
// for (String name : nameParts) {
// initials += name.charAt(0);
// }
// System.out.println("Your initials are: " + initials.toUpperCase());
// 0
// scanner.close();
// }
// }
// An anagram is a word or a phrase made by transposing the letters of another word or phrase; for example, "parliament" is an anagram of "partial men," and "software" is an anagram of "swear oft." Write a program that figures out whether one string is an anagram of another string. The program should ignore white space and punctuation.