I NEED SERIOUS HELP WITH JAVA SHAPES PROJECT IT HAS TO BE CRUEL JOKE.... | Sololearn: Learn to code for FREE!

0

I NEED SERIOUS HELP WITH JAVA SHAPES PROJECT IT HAS TO BE CRUEL JOKE....

I've tried everything for weeks... I've typed in so many random sequences of characters that the laws of probability say I should've gotten it right because nothing else could possibly be wrong-- It's rigged.... I understand the syntax and concept it is something wrong with this app do not need syntax I understand clearly it works fine in my compiler-- need answer to mark it off as right so I can be done with Java portion on this app... Thank you in advance :-) import java.util.Scanner; //import java.lang.Math* abstract class Shape { int width; abstract void area(); } public class Square extends Shape{ Square(int x){ width=x; } public void area(){ System.out.println(width*width); } public class Circle extends Shape{ Circle(int y){ width = y; } public void area(){ System.out.println(Math.PI*width*width); } } } public class Program { public static void main(String[ ] args) { Scanner sc = new Scanner(System.in)

1/27/2022 9:36:11 AM

Kevin Merric

19 Answers

New Answer

+3

G'day Kevin Merric I feel your pain!!! Update/edit your question to include your code, someone will be able to discover the reason. Good luck! I've had many situations (coding in C) where I failed to cover the zero or equal situation. Other times it made a difference locating division after multiplication in my algorithms (BODMAS/PEMDAS order shouldn't be wrong, but maybe it's binary rounding?)

+3

You should link the code instead. Typing it as a message here makes it very hard to check. It might be just a typo. But copy paste seems to be disabled in the message body here in Sololearn. Retyping it in a new java file is too much work to ask for people trying to help. Your code looks ok, very similar to my solution, but it is not easy to verify if you present it this way. Open a new java file and copy paste your solution into it, then link it here. Or just copy Ausgrindtube 's code and paste it in your solution. Do not re-type. Directly select all then copy then paste. I have a feeling it might just be a typographical error in your code.

+2

This above doesn't work

+2

Kevin Merric you might kick yourself, but the code works for me and the only difference I can see is that I don't have the word "public" in front of "public void area()". Remove those 2x public and see if it works.

+2

I don't know why you added static... Let's see if this works. https://code.sololearn.com/ci00aSbO4Yqq/?ref=app

+2

on class square u forget to close the bracket at the end, and on class circle u have an extra curly bracket at the end.

+2

HungryTradie you have to take care with Seppos ;)

+1

Pls edit your question including: 1. Link to your code from code playground (use + button) 2. Project description (copy and paste is OK) 3. Your difficulties/problems/errors - in the case of errors, do copy and paste, never rewrite. 4. Tag with only the language And removing: 1. Non related tags (that is, all the current ones) 2. All-capitalized text - means screaming This allows for useful help

+1

Show us your code, otherwise you're just shouting in the wind

+1

Will do shortly...

+1

Kevin Merric , this is even harder to evaluate. Pls follow the instructions I sent above. At the very minimum, the first 3 steps. Otherwise, I don't know what you're trying to do nor what's not OK - there could be even a typo not shown in the answers, or hard to spot in them. Pls help us help you.

+1

So what did the rigged app stop you from doing when you perfectly understood the syntax etc?

0

import java.util.Scanner; //import java.lang.Math* abstract class Shape { int width; abstract void area(); } public class Square extends Shape{ Square(int x){ width=x; } public void area(){ System.out.println(width*width); } public class Circle extends Shape{ Circle(int y){ width = y; } public void area(){ System.out.println(Math.PI*width*width); } } } public class Program { public static void main(String[ ] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int y = sc.nextInt(); Square a = new Square(x); Circle b = new Circle(y); a.area(); b.area(); } } /*You are working on a graphical app, which includes multiple different shapes. The given code declares a base Shape class with an abstract area() method and a width attribute. You need to create two Shape subclasses, Square and Circle, which initialize the width attribu

0

Will try and remove public now ...

0

Tried removing public didn't work... Added static to public eeeng wrong again... It will not work... If one of you figured it out plz copy and paste what you did so I can move on from this...

0

FIGURED IT OUT: import java.util.Scanner; abstract class Shape { int width; abstract void area(); } class Square extends Shape{ public int area2; public Square(int x) { width=x; } public void area() { area2=width*width; System.out.println(area2); } } class Circle extends Shape { public double area1; public Circle(int y) { width=y; } public void area() { area1=Math.PI*width*width; System.out.println(area1); } } public class Program { public static void main(String[ ] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int y = sc.nextInt(); Square a = new Square(x); Circle b = new Circle(y); a.area(); b.area(); } }

0

Yeah yeah yeah

-1

You asked for it, here is my code (I even did it by putting numbers they mentioned in instructions e.g. 2*2 and 5*5. I believe they used 2 for PI because they're implementing an integer instead of floating poing.... Here is goes plz help: import java.util.Scanner; //import java.lang.Math* abstract class Shape { int width; abstract void area(); } public class Square extends Shape{ Square(int x){ width=x; } public void area(){ System.out.println(width*width); } public class Circle extends Shape{ Circle(int y){ width = y; } public void area(){ System.out.println(Math.PI*width*width); } } } public class Program { public static void main(String[ ] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int y = sc.nextInt(); Square a = new Square(x); Circle b = new Circle(y); a.area(); b.area(); } } /*You are working on a graphical

-2

Why doesn't it work (Java Shapes project)??? import java.util.Scanner; //import java.lang.Math* abstract class Shape { int width; abstract void area(); } public class Square extends Shape{ Square(int x){ width=x; } public void area(){ System.out.println(width*width); } public class Circle extends Shape{ Circle(int y){ width = y; } public void area(){ System.out.println(Math.PI*width*width); } } } public class Program { public static void main(String[ ] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int y = sc.nextInt(); Square a = new Square(x); Circle b = new Circle(y); a.area(); b.area(); } }