Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

Programming Guides, Tutorials, Web Resources, and E-books Compilation

hi pooo pwede pong patulongg? ganito po kasiii, ahm di po ako makagaw ng program sa java na may parameters na random numbers gagamitin, random rn = new Random

ano po ba mali dito?

import java.util.Random;
import java.util.Scanner;

public class forloop {
{
}
public static void main(String[] args) {
int a=0;
int b=0;
int c=0;
int d=0;
Scanner input = new Scanner(System.in);


Addme();
Printperimeter();
Printanswer();
}

{

System.out.println("Note: Find the perimeter of the trapezoid by using the formula perimeter = a + b + c + d .");
for (int x=1; x<=10; x++){
System.out.println("\nProblem # " +x);

}
}



}

static void Addme() {
Random rn = new Random();
a = rn.nextInt(100);
System.out.println("a= " +a);
b = rn.nextInt(100);
System.out.println("b= " +b);
c = rn.nextInt(100);
System.out.println("c= " +c);
d = rn.nextInt(100);
System.out.println("d= " +d);

}


static void Printperimeter() {
System.out.print("What is the perimeter? ");
perimeter = input.nextInt();
int correct_ans= a + b + c + d;

}

static void Printanswer() {
if(perimeter == correct_ans)
System.out.println("You are correct");
else
System.out.println("Your answer is wrong");
}



}

please po patulong, di ako makatulog :<
 
grabe ang solid nito! ngayon pa lang ako papasok sa mundo ng programming, sana kayanin ko haha
 
hi pooo pwede pong patulongg? ganito po kasiii, ahm di po ako makagaw ng program sa java na may parameters na random numbers gagamitin, random rn = new Random

ano po ba mali dito?

import java.util.Random;
import java.util.Scanner;

public class forloop {
{
}
public static void main(String[] args) {
int a=0;
int b=0;
int c=0;
int d=0;
Scanner input = new Scanner(System.in);


Addme();
Printperimeter();
Printanswer();
}

{

System.out.println("Note: Find the perimeter of the trapezoid by using the formula perimeter = a + b + c + d .");
for (int x=1; x<=10; x++){
System.out.println("\nProblem # " +x);

}
}



}

static void Addme() {
Random rn = new Random();
a = rn.nextInt(100);
System.out.println("a= " +a);
b = rn.nextInt(100);
System.out.println("b= " +b);
c = rn.nextInt(100);
System.out.println("c= " +c);
d = rn.nextInt(100);
System.out.println("d= " +d);

}


static void Printperimeter() {
System.out.print("What is the perimeter? ");
perimeter = input.nextInt();
int correct_ans= a + b + c + d;

}

static void Printanswer() {
if(perimeter == correct_ans)
System.out.println("You are correct");
else
System.out.println("Your answer is wrong");
}



}

please po patulong, di ako makatulog :<


JavaScript:
import java.util.Random;
import java.util.Scanner;

public class ForLoop {
    static int a; // Declare variables as static to access them within static methods
    static int b;
    static int c;
    static int d;
    static int perimeter; // Declare the perimeter variable

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

        addNumbers(); // Renamed the method to follow Java naming conventions
        printPerimeter(input);
        printAnswer();
    }

    static void addNumbers() {
        Random rn = new Random();
        a = rn.nextInt(100);
        System.out.println("a = " + a);
        b = rn.nextInt(100);
        System.out.println("b = " + b);
        c = rn.nextInt(100);
        System.out.println("c = " + c);
        d = rn.nextInt(100);
        System.out.println("d = " + d);
    }

    static void printPerimeter(Scanner input) {
        System.out.println("Note: Find the perimeter of the trapezoid by using the formula perimeter = a + b + c + d.");
        System.out.print("What is the perimeter? ");
        perimeter = input.nextInt();
    }

    static void printAnswer() {
        int correct_ans = a + b + c + d; // Declare and calculate the correct_ans variable
        if (perimeter == correct_ans) {
            System.out.println("You are correct ✅");
        } else {
            System.out.println("Your answer is wrong ❌");
        }
    }
}
 
Back
Top Bottom