im tyinh to writ a program to calculate nd display the volum ,area as well as the area of 6 sides of the rectangular prism but im stuck lol im a beginners


import java.util.Scanner;
public class RectangularPrism {


public static void main(String[] args) {


int length;
int width;
int height;
String units;
int volume;
int surfaceArea;

}

void Get_Input()
{

// 1. Ask user for length, validate input.
Scanner input = new Scanner (System.in);
System.out.println("Enter length > 0 ");
int length = input.nextInt();

// 2. Ask user for width, validate input.
System.out.println("Enter width > 0 ");
int width = input.nextInt();
// 3. Ask user for height, validate input.
System.out.println("Enter height > 0 ");
int height = input.nextInt();
}

int Calculate_volume(int length, int width, int height)
{

Scanner input = new Scanner (System.in);
int volume = length * width * height;
return volume = input.nextInt();
}

int Calculate_surfacearea(int length, int width, int height)
{

Scanner input = new Scanner (System.in);
int surfaceArea = (2 * length * height) + (2 * width * length) + (2 * width * height);
return surfaceArea = input.nextInt();

}
void Display(int volume, int surfaceArea, int length, int width, int height, String units)
{

What is your problem? Can you compile? Do you get errors? If so, copy paste which errors you receive.

they said that all my variable ar not read

Please paste the full error you are receiving.

error
Description Resource Path Location Type
The local variable height is never read RectangularPrism.java /projet1/src line 14 Java Problem
The local variable height is never read RectangularPrism.java /projet1/src line 35 Java Problem
The local variable length is never read RectangularPrism.java /projet1/src line 12 Java Problem
The local variable length is never read RectangularPrism.java /projet1/src line 28 Java Problem
The local variable surfaceArea is never read RectangularPrism.java /projet1/src line 17 Java Problem
The local variable surfaceArea is never read RectangularPrism.java /projet1/src line 57 Java Problem
The local variable units is never read RectangularPrism.java /projet1/src line 15 Java Problem
The local variable volume is never read RectangularPrism.java /projet1/src line 16 Java Problem
The local variable volume is never read RectangularPrism.java /projet1/src line 44 Java Problem
The local variable width is never read RectangularPrism.java /projet1/src line 13 Java Problem
The local variable width is never read RectangularPrism.java /projet1/src line 32 Java Problem

well first of all , every variable you declared are in main method.
They are hence local variables and you didnt call any function from your main method.
Well almost everyting is wrong with your program.

You have written your code logic in separate functions that you do not call in the main method. You should call the methods in main(), or write the logic directly in the main method.

how can i do that

Well, first of all as it was previously mentioned here - you can declare your variables in the class type definition like this

import java.util.Scanner;
public class RectangularPrism {
//Declaring the variables

int length;
int width;
int height;
String units;
int volume;
int surfaceArea;

public static void main(String[] args) {
...

Then, if you want to execute the piece of code inside the Get_Input() function, you just create an instance(object) of the class, and call the method using that object. That happens inside the main() method. Like this:

public static void main(String[] args) {
      RectangularPrism prism = new RectangularPrism();
      prism.Get_Input();

And now you have called the Get_Input() method and all of the action inside of it will take place. Now, since this is not the proper way of doing things(me giving you the code) I will instruct you to read some tutorials about basic Object-oriented programming, and Starting Java. You have an excellent starting point here - http://download.oracle.com/javase/tutorial/java/concepts/ Read through the tutorials, and try the things yourself, try plating around with objects and classes. I hope you'll find it interesting. Regards

thay said that the method get_Input is undefined for the type RectangularPrism

thay said that the method get_Input is undefined for the type RectangularPrism

Make sure you have the correct spelling, methods are case sensitive so make sure you have the capital letters in the correct place. And dont forget, the Get_Input method is void,
so you should have empty brackets at the end.

Get_Input()

i did that but i still hav some errors thx anyway

i did that but i still hav some errors thx anyway

Dude why don't you give us some details of the errors?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.