Design a superclass called shape that contains two functions

Assignment Help JAVA Programming
Reference no: EM131119722

Program 1- Sum of Digits in a String. HINT: You will need to create a utility procedure that allows you to convert from a character to an integer value to allow you to sum the values of the digits in a string. Also, Raptor will not allow you to input a numeric value and treat it as a String input. To work around this limitation, I would recommend putting a character like 'a' somewhere in your input value so Raptor will treat the input as a String data type. Your program should be designed in such a way that it will ignore any non-numeric characters in the input string.

Program 2 - Area of Shapes

Design a superclass called Shape that contains two functions-getArea() and getInput(). The getArea and getInput functions in the Shape class will simply return 0, you will derive from them in your subclasses mentioned below. Define 3 subclasses of the Shape class-circle, rectangle, and triangle. The circle class will need a radius field, the rectangle class will need length and width fields, and the triangle class will need base and height fields. Declare all of the appropriate setters and getters for each of these classes. The circle class will calculate it's area as PI*r*r. The rectangle's area is length * width. The triangle's area is .5 * base * height. Override the getInput method for each subclass so it will prompt the user to input the dimensions for each shape. Then, override the getArea method in each subclass so it will calculate and return the area of the shape.

Demonstrate your classes be writing a menu driven program that allows the user to select which shape they want to create. After making their selection, the program will call getInput on the object to ask the user to input the appropriate dimensions for that shape. The program should then display the area for that shape. The menu will continue to display until the user chooses to quit.

Example Output:

Please select an option:

1) Area of a circle

2) Area of a rectangle

3) Area of a triangle

4) Quit

Enter your selection:

2 [Enter]

Enter the rectangle length:

10 [Enter]

Enter the rectangle width:

25 [Enter]

The area for your rectangle is 250

Please select an option:

1) Area of a circle

2) Area of a rectangle

3) Area of a triangle

4) Quit

Enter your selection:

4 [Enter]

Thanks for playing!

Reference no: EM131119722

Questions Cloud

Compare valanis criteria for a good screening program : Compare Valanis's criteria for a good screening program with the eight criteria which the ACC/American Heart Association (AHA) panel proposed for selection of a screening procedure
With social media proving to be a cost-effective way : With social media proving to be a cost-effective way to attract park visitors, should SeaWorld abandon its other promotional efforts and focus everything on social media? Why or why not? What steps can SeaWorld take to maintain a relation-ship with c..
Various forms of literature to understand areas : Throughout this course, you have explored the use of various forms of literature to understand areas of women's life experience. Consider how each author achieved a piece of a social change vision through her work.
Hat average level of inventory should the firm maintain : Vanity Press, Inc., has annual credit sales of $1,600,000 and a gross profit margin of 35 percent. a. If the firm wishes to maintain an average collection period of 50 days, what level of accounts receivable should it carry?  b. The inventory turnove..
Design a superclass called shape that contains two functions : Design a superclass called Shape that contains two functions-getArea() and getInput(). The getArea and getInput functions in the Shape class will simply return 0.
Consumers really make up our own minds in market economy : Marketing Marketing Is more than Just advertising. It consists of all that Is done to get the product Into the hands of the consumer. Much of marketing is pyschological. Companies spend millions trying to figure out what the hot buttons are that will..
Recognition of profit and balance sheet presentation : Prepare a partial balance sheet for December 31, 2011, showing the balances in the receivable and inventory accounts.
What is the relationship between eva and mva : What is the relationship between EVA and MVA?
Adult criminal justice system : DISCUSS the aspects of a cohort and the significant findings at its conclusion - Compare and contrast the three primary models for dealing with status offenders.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write a definite loop in java

True or False: To write a "definite loop" in Java, you use a loop control variable that has its value modified upon each iteration of the loop

  User-defined methods

You will create the ShoutBox class for your Virtual World. Your ShoutBox class will have a shoutOutCannedMessage() method that returns a String type.

  Size of the frame to be set a little bit larger than content

I need the size of the frame to be set a little bit larger than its content, which is a label. Also, the location could be set so that it could be appeared not at the upper left corner of the screen. And we can set the foreground and background co..

  Implement a class called fulladdress and inherit it

I need assistance in commenting on the enclosed code, consider things like code layout, use of variable names, general readability and understandability.

  Write an application that reads determines the surface area

Write a program that uses the top five countries' National Wealth to calculate the average of those five countries.

  Object-oriented gui drawing editor

A simple object-oriented GUI drawing editor that allows a user to create, move and erase rectangles, squares, circles and lines in an interactive graphics. How can I draw move erase rectangles, squares, circles and lines in GUI/java.

  One search function

One search function will use a sentinel to mark the end of the array. The other search function will use an array length (maximum legal index into the array) to determine when to exit the search loop. Both functions must return true when the searc..

  Explain the meaning of polymorphism

Explain the meaning of polymorphism

  Java programming using netbeand

Java Programming using Netbeand- In this assignment, you will be asked to demonstrate what you have learned in the Discussion Board in terms of vector, wrapper classes, conversion, and collection data structures by writing and implementing Java co..

  Java program that prompts the user to input three numbers

Need a java program that prompts the user to input three numbers. This program should then output the numbers in nondescending order

  Write a method that takes a string as input and returns

Write a method that takes a String as input and returns the reverse of that String. Then write a second method that uses the first method to test whether or not an input String is a palindrome.

  Write the source code for each class in a separate file

Write the source code for each class in a separate file, which must have the same name as the class name together with the extension. java. Class names commence with a capital letter

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd