Skip to content

Instantly share code, notes, and snippets.

View L8RFN's full-sized avatar
💭
Busy.

Qusai Bin Elayyan L8RFN

💭
Busy.
  • Middle East
  • 01:39 (UTC +03:00)
View GitHub Profile
@L8RFN
L8RFN / Mehods.java
Last active May 10, 2023 14:27
محاضرة المدمج للاسبوع الاول في الميثود
package javaapplication18;
//5!= 5*4*3*2*1=120 = 5 * 4!
//1!=1
//0!=1 //IMPORTANT
//A LITTLE IMPORTANT... write method that takes base as paramneter and power as parameter and return base ^ power 2 ,3 =8 4,2 =16
//write method named isprime(اولي) and determine if it is prime or not
//that takes inetger prime number divisible by one and itself only , method it will return true if number is prime otherwise it will false
/*
//A LITTLE IMPORTANT... write method named checkrangeprime that takes two intgere and print if each number is prime or not prime in this range
import javax.swing.*;
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
System.out.println(max(1, 2)); //call error //Ambiguous method call.// 1 can be stored in double and 2 can be stored in double.
//so the compiler would never know which method you meant to call.
//some solutions:
int [5] name = {1,2,3,4,5};
int [5] name2 = {1,2,3};
int [] name3 = {1,2,3,4,5};//array of size 5 has been declared.
int name4[];//no error// NULL array has been declared.
name4 = {1,32,32,2};//error// it must be an initial value to use this fast way // like line 3
name3 = {1,3,2}; //error// I tried to resize name3 using this way, an error occurred.
name3 = new int [4];//no error// I tried to resize name3 using this way, no error occurred.
int test[] = new int [10];
test={1,2,3};//error, you cant fill array like this.
import javax.swing.*;
import java.util.Scanner;
//Question One (Random):
//1. Write a method calculateRightAnswer that takes two integers and returns their summation.
//2. Write a method checkAnswer that takes three integers. The method should check whether
//the summation of the first two integers equals the third. If so, the method should return
//(true), otherwise, the method should return (false).
// Hint: use the calculateRightAnswer method.
//3. Implement the main() method as follows:
//a. Generate two integer values randomly in the range [1-10].
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
System.out.println("Please enter n");
int n = cin.nextInt();
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= i; j++) {
// If the row number is odd
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
System.out.println("Please enter the number of students.");
int numOfStudents = cin.nextInt();
System.out.println("Please enter each student name and mark.");
String name=null,nameMax=null,nameSec=null,nameMin=null;
int mark;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
for (int l=1; l <=6; l++) {
for (int j = 5; j >= l; j--)
System.out.print(" ");
for(int f=l ;f>=1;f--)
System.out.print(f);
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Scissor (0), Rock (1), Paper (2): ");
int userInput = scanner.nextInt();
int computerInput = (int) (Math.random() * 3);
import java.util.Scanner;
public class L8R {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a number: ");
int number = scanner.nextInt();
System.out.print("Enter the width: ");
int width = scanner.nextInt();
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int rows = cin.nextInt();
for (int i = 1 ;i<=rows;i++)
{
for (int j = 1; j <=i ; j++)
{