package week6;
import [Link];
public class DecToBin {
static void tobinary(int u){
String Binary = "";
while(u > 0){
Binary += (u % 2);
u /= 2;
}
[Link](Binary);
}
public static void main(String[] args){
Scanner g = new Scanner([Link]);
int k = [Link]();
tobinary(k);
}
}
Acrivity 2:
package week6;
import [Link];
public class ArrayShiftTest {
static void Test(int[] u){
int[] p = new int[[Link]];
for(int i = 0; i < [Link] - 1; i++){
p[i] = u[i + 1];
}
p[[Link] - 1] = u[0];
for(int i = 0; i < [Link]; i++){
[Link](p[i] + " ");
}
}
public static void main(String[] args){
Scanner j = new Scanner([Link]);
int n = [Link]();
int[] array = new int[n];
for(int i = 0; i < [Link]; i++){
array[i] = [Link]();
}
Test(array);
}
}
Activity 3:
package week6;
import [Link];
public class FloatArrayInspect {
static void yc(float[] o){
float sum = 0;
float max = -99999;
float min = 99999;
for(int i = 0; i < [Link]; i++){
sum += o[i];
if(o[i] > max){
max = o[i];
}
if(o[i] < min) {
min = o[i];
}
}
double k = sum / 2;
k = [Link](k * 100) / 100.0;
double range = max - min;
range = [Link](range * 100) / 100.0;
[Link]("The average of the values is: " + k);
[Link]("The smallest of the values is: " + min);
[Link]("The largest of the values is: " + max);
[Link]("The range is: " + (max - min));
}
public static void main (String[] args){
Scanner f = new Scanner([Link]);
int e = [Link]();
float[] u = new float[e];
for(int i = 0; i < e; i++){
u[i] = [Link]();
}
yc(u);
}
Activity 4:
package week6;
import [Link];
import [Link];
public class PlayWithString {
static void testa(String k) {
String e = "";
for (int i = [Link]() - 1; i >= 0; i--) {
if ([Link](i) >= 'A' && [Link](i) <= 'Z') {
e += [Link](i);
}
}
[Link]("Only the uppercase letters in the string: " + e);
}
static void testb(String n) {
for (int i = 0; i < [Link](); i++) {
if ((([Link](i) >= 'A' && [Link](i) <= 'Z') || ([Link](i) >=
'a' && [Link](i) <= 'z')) && i % 2 == 0) {
[Link]([Link](i));
}
}
}
static void testc(String h){
char p = '_';
for(int i = 0; i < [Link](); i++){
char d = [Link](i);
if((d == 'A' || d == 'U' || d == 'I' || d == 'E' || d == 'O') || (d
== 'a' || d == 'u' || d == 'i' || d == 'e' || d == 'o' )) {
h = [Link](d, p);
}
}
[Link](h);
static void testd(String f){
f = [Link]();
int cnt = 0;
for (int i = 0; i < [Link](); i++) {
char h = [Link](i);
if (h == 'A' || h == 'U' || h == 'I' || h == 'E' || h == 'O')
{
++cnt;
}
}
[Link]("Number of vowels in the string: " + cnt);
}
static void teste(String j){
j = [Link]();
[Link]("The positions of all vowels in the string are: ");
for(int i = 0; i < [Link](); i++) {
char h = [Link](i);
if (h == 'A' || h == 'U' || h == 'I' || h == 'E' || h == 'O') {
[Link](i + " " );
}
}
}
public static void main(String[] args){
Scanner j = new Scanner([Link]);
String hay = [Link]();
//testa(hay);
//testb(hay);
testc(hay);
//testd(hay);
//teste(hay);
}
}
Activity 5:
package week6;
import [Link];
public class Palindrome {
static void testpalindrome(int u){
int k = 0, l = u;
while(u != 0){
k = k * 10 + u % 10;
u /= 10;
}
if(k == l){
[Link](l + " is a palindrome number");
} else {
[Link](l + " is not a palindrome number");
}
}
static void test2(int u){
String m1 = [Link](u), m2 = "";
for(int i = [Link]() - 1; i >= 0; i--){
char p = [Link](i);
m2 += p;
}
[Link](m2);
if([Link](m2) == true){
[Link](u + " is a palindrome number");
} else {
[Link](u + " is not a palindrome number");
}
}
public static void main(String[] args){
Scanner j = new Scanner([Link]);
int palindrome = [Link]();
test2(palindrome);
}
}
Activity 6:
package week6;
import [Link];
public class FilledAndHollowSquare {
public static void Testshap(int n) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
[Link]("*");
}
[Link](" ");
for (int j = 0; j < n; j++) {
if (i == 0 || i == n - 1 || j == 0 || j == n - 1) {
[Link]("*");
} else {
[Link](" ");
}
}
[Link]();
}
}
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
[Link]("Enter the side length: ");
int n = [Link]();
Testshap(n);
}
}