Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Commit

Permalink
Uploading Files
Browse files Browse the repository at this point in the history
  • Loading branch information
ArviinM authored Jul 17, 2020
1 parent 098a179 commit 87bec6a
Show file tree
Hide file tree
Showing 43 changed files with 478 additions and 0 deletions.
Binary file added Array01.class
Binary file not shown.
25 changes: 25 additions & 0 deletions Array01.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import java.util.Scanner;
public class Array01{
public static void main(String [] args){
Scanner sc = new Scanner(System.in);

int i, num ;
System.out.print("Enter Length of Array: ");
num = sc.nextInt();

int [] arr = new int[num];
System.out.println("Enter " + num + " Elements: ");
for (i = 0; i <num;i++){
arr[i] = sc.nextInt();
}
System.out.println("Elements in Array");
for(i = 0; i<num; i++){
System.out.print(arr[i] + "\t");
}
int sum = 0;
for(i = 0; i<num; i++){
sum += arr[i];
}
System.out.println("\r\rSum is: " + sum);
}
}
Binary file added Array02.class
Binary file not shown.
26 changes: 26 additions & 0 deletions Array02.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import java.util.Arrays;
import java.util.Scanner;
import java.util.Collections;
public class Array02{
public static void main(String [] args){
Scanner sc = new Scanner(System.in);

int i, num;
System.out.print("Enter length of array: ");
num = sc.nextInt();

int[] arr1 = new int[num];
int[] arr2 = new int[num];
System.out.println("Enter " + num + " elements: ");
for (i = 0; i < num; i++){
arr1[i] = sc.nextInt();
}

Arrays.sort(arr1);
System.out.println("\rElements of array2 are: " + Arrays.toString(arr1));

Collections.reverse (Arrays.asList(arr1));
System.out.println("\rElements of array2 are: " + Arrays.toString(arr1));

}
}
Binary file added Array03.class
Binary file not shown.
24 changes: 24 additions & 0 deletions Array03.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import java.util.Arrays;
import java.util.Scanner;
public class Array03{
public static void main(String [] args){
Scanner sc = new Scanner(System.in);
int i, num;
System.out.print("Enter length of array: ");
num = sc.nextInt();

int[] arr = new int[num];
System.out.println("Enter " + num + " elements: ");
for(i = 0; i<num; i++){
arr[i] = sc.nextInt();
}
Arrays.sort(arr);
System.out.print(Arrays.toString(arr));

int sum = 0;
for(i = 0; i < num; i++){
sum += arr[i];
}
System.out.println("Sum is: " + sum);
}
}
Binary file added Array1.class
Binary file not shown.
8 changes: 8 additions & 0 deletions Array1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
public class Array1{
public static void main(String [] args){
double prices[] = {12.43,13.42,13.23,15.00,25.00};
for (int i=0; i < prices.length; i++){
System.out.println(prices[i]);
}
}
}
Binary file added Binary1.class
Binary file not shown.
12 changes: 12 additions & 0 deletions Binary1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import java.util.Scanner;
public class Binary1{
public static void main(String args []){
int n;
Scanner sc = new Scanner(System.in);

System.out.print("Enter any number: ");
n = sc.nextInt();
System.out.println("Binary number: " + Integer.toBinaryString(n));

}
}
Binary file added Conditions1.class
Binary file not shown.
32 changes: 32 additions & 0 deletions Conditions1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
*Scanner dahil static na program
*or with user input.
*Reminders:
*This may or may totally not be
*included sa activity tomorrow
*Thank you <3
*/

import java.util.Scanner;
public class Conditions1 {
public static void main (String [] args){
Scanner sc = new Scanner(System.in);
double no; //no is number

System.out.print("Input your grade: ");
no = sc.nextDouble();

if (no >= 90){
System.out.print("A");
} else if (no >= 80){
System.out.print("B");
} else if (no >= 75){
System.out.print("C");
} else if (no < 50 || no > 100){
System.out.print("Input Error");
} else {
System.out.print("F");
}

}
}
18 changes: 18 additions & 0 deletions Conversion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Data Type Conversion
*/
public class Conversion {
public static void main(String[] args) {

//variable x is float data type
float x = 2.89f;
//variable y is an integer data type
int y = (int) x;
//float x will be convert to integer
System.out.println("Float to Int: " + y);
//displays y into integer
//output should be 2

}

}
Binary file added Conversion1.class
Binary file not shown.
13 changes: 13 additions & 0 deletions Conversion1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public class Conversion1 {
public static void main (String[] args){
final int grade = 80;
final int size = 20;
double final_grade = (double) grade;
double final_size = (double) size;

//Displays final size and final grade variables
System.out.println(final_grade);
System.out.println(final_size);

}
}
Binary file added Conversion2.class
Binary file not shown.
11 changes: 11 additions & 0 deletions Conversion2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
public class Conversion2 {
public static void main (String[]main) {
String str = "1050";

int inum = Integer.parseInt(str);
System.out.println(inum);

int onum = Integer.valueOf(str);
System.out.println(onum);
}
}
Binary file added DoWhile1.class
Binary file not shown.
Binary file added Exception01.class
Binary file not shown.
30 changes: 30 additions & 0 deletions Exception01.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import java.util.*;
public class Exception01{
public static void main(String [] args){
Exception01 ex = new Exception01();
ex.input();
}
public void input(){
Scanner sc = new Scanner(System.in);
int dividend, divisor, quotient;
System.out.print("Enter dividend: ");
dividend = sc.nextInt();
System.out.print("Enter divisor: ");
divisor = sc.nextInt();
try{
quotient = dividend / divisor;
System.out.print(dividend + " / " + divisor + " = " + quotient);
}
catch(ArithmeticException e){
System.out.println("Divisor cannot be 0");
System.out.println("Try again.");
}
catch(InputMismatchException e){
System.out.print("Wrong data type!");
System.out.println("Try again.");
}
finally{
System.out.println("\rThank you!");
}
}
}
Binary file added ForLoop1.class
Binary file not shown.
15 changes: 15 additions & 0 deletions ForLoop1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import java.util.Scanner;
public class ForLoop1 {
public static void main (String [] args){

Scanner sc = new Scanner(System.in);
int num;

System.out.print("Enter a positive number: ");
num = sc.nextInt();

for (int i = 1; i<=10; i++){
System.out.println(num + " x " + i + " = " + (num*i) );
}
}
}
Binary file added ForLoop2.class
Binary file not shown.
20 changes: 20 additions & 0 deletions ForLoop2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import java.util.Scanner;
public class ForLoop2 {
public static void main(String [] args){
int base, power;
int result = 1;

Scanner sc = new Scanner(System.in);

System.out.print("Enter the base number: ");
base = sc.nextInt();

System.out.print("Enter the power number: ");
power = sc.nextInt();

for(int i = 1; i<= power; i++){
result *= base;
}
System.out.println("Result: " + result);
}
}
12 changes: 12 additions & 0 deletions Hello.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Hello
*/
public class Hello {
//main method
public static void main(String[] args) {
//Variable x is a string
String x = "Hello Arvin";
//Says Hello Arvin
System.out.println(x);
}
}
Binary file added Measurements.class
Binary file not shown.
37 changes: 37 additions & 0 deletions Measurements.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import java.util.Scanner;
public class Measurements{
public static void main(String [] args){
Scanner sc = new Scanner(System.in);
double num;
double cm = 0;
String measurement = "";
String converter = "";

System.out.println("Available measurements are: millimeter (mm), centimeter (cm)");
System.out.print("Enter a measurement: ");
measurement = measurement.toLowerCase();
measurement = sc.nextLine();

System.out.print("Enter a number: ");
num = sc.nextDouble();

if(measurement.equals("mm")|| measurement.equals("millimeter")){

System.out.println("Available conversion to: centimeter (cm)");
System.out.print("Convert number to: ");
converter = converter.toLowerCase();
converter = sc.nextLine();

if(converter.equals("cm")||converter.equals("centimeter")){
cm = num / cm;
System.out.println("Length in centimeter is: " + cm);
} else{
System.out.println("Error, converter not found.");
}
} else if(measurement.equals("cm")|| measurement.equals("centimeter")){
System.out.println("test");
} else {
System.out.print("Error");
}
}
}
Binary file added MyLoopTest.class
Binary file not shown.
11 changes: 11 additions & 0 deletions MyLoopTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import java.util.Scanner;
public class MyLoopTest {
public static void main(String [] args){
int sum = 0;
for(int a=0; a<=100; a+=2){
System.out.println(a);
//sum += a;
}
//System.out.print(sum);
}
}
37 changes: 37 additions & 0 deletions Recursion07.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import java.util.Scanner;
class Recursion07{
public static void reverse(int arr[], int start, int end){
if(start >= end)
return;
int temp;
temp = arr[start];
arr[start] = arr[end];
arr[end] = temp;

reverse(arr, start+1, end-1);
}

public static void main(String args[]){
Scanner sc = new Scanner(System.in);

System.out.println("Enter Row Array Elements: ");
int n = sc.nextInt();

System.out.println("Enter Array Elements: ");
int arr[] = new int[n];
for(int i = 0; i<n; i++){
arr[i]=sc.nextInt();
}
System.out.println("Array Elements: ");
for(int i = 0; i<n; i++){
System.out.println(arr[i]);
}

System.out.println("Reversed Array Elements: ");
reverse(arr, 0, n-1);
for(int i = 0; i<n; i++){
System.out.println(arr[i]);
}

}
}
Binary file added SampDoWhile.class
Binary file not shown.
12 changes: 12 additions & 0 deletions SampDoWhile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public class SampDoWhile{
public static void main(String [] args){
int i = 0;
do{
if (i==0){
System.out.print("Done");
} else{
System.out.print("Oops");
}
} while(true);
}
}
Binary file added Scanner1.class
Binary file not shown.
Loading

0 comments on commit 87bec6a

Please sign in to comment.