•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 391,588 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,656 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 270 | Replies: 2 | Solved
![]() |
Two arrays length 10. In one you will put the squares and at the other the cubes.
Use a for loop from 0 to 10. Calculate inside the loop theresults and put them in the array:
Use a for loop from 0 to 10. Calculate inside the loop theresults and put them in the array:
square[i] = i*i; cube[i] = i*i*i;
I AM the 12th CYLON
•
•
Join Date: Jul 2008
Posts: 92
Reputation:
Rep Power: 1
Solved Threads: 0
You can do this without Arrays as well.
Since this is solved, I will just post full code
Use buffer reader
----
EDIT: /facepalm, didnt see he said no input. ARG
Since this is solved, I will just post full code
Use buffer reader
----
java Syntax (Toggle Plain Text)
import java.io.*; public class Square { public static void main(String[] args){ int s=0; try{ BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter Length of a Side : "); s = Integer.parseInt(br1.readLine()); double area = s*s; System.out.println("Area of Square : "+area); double volume =s*s*s ; System.out.println("Volume of Cube : "+volume); } catch(Exception e){ System.out.println("Error : "+e); } } }
EDIT: /facepalm, didnt see he said no input. ARG
Last edited by bloody_ninja : 28 Days Ago at 3:44 am.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Java Marketplace
Other Threads in the Java Forum
- Previous Thread: Can I do System Programming with Java
- Next Thread: java homework help!!


Linear Mode