Create class named PIZZA.
Data field include a string for toppings( such as pepperoni), an integer for diameter in inches (such as 12), and a double for price(such as as 23.70).
Include methods to get and set values for each of these fields.
B. Create an application name TESTPizza the instantiates one demonstrate the use of Pizza set and get methods. Save the application TestPizza.java
Create a class named INVOICE that contains fields for an item number, name, quantity, price, and total cost. Create instance methods that set the item name, quantity, and price. Whenever the price or quantity is set , recalculate the total (price times quantity ). Also include a DISPLAYLine() method that displays the item number, name, quantity, price for each INVOICE. Save the class as INVOICE.java
a) Write a class called Square, as a subclass of Rectangle. Convince yourself that Square can be modeled as a subclass of Rectangle. Square has no instance variable, but inherits the instance variables width and length from its superclass Rectangle.
· Provide the appropriate constructors (as shown in the class diagram). Hint:
public Square(double side) {
super(side, side); // Call superclass Rectangle(double, double)
}
· Override the toString() method to return "A Square with side=xxx, which is a subclass of yyy", where yyy is the output of the toString() method from the superclass.
· Do you need to override the getArea() and getPerimeter()? Try them out.
· Override the setLength() and setWidth() to change both the width and length, so as to maintain the square geometry.
a) The Rectangle class contains:
· Two instance variables width (double) and length (double).
· Three constructors as shown. The no-arg constructor initializes the width and length to 1.0.
· Getter and setter for all the instance variables.
· Methods getArea() and getPerimeter().
· Override the inherited toString() method, to return "A Rectangle with width=xxx and length=zzz, which is a subclass of yyy", where yyy is the output of the toString() method from the superclass.
Write two subclasses of Shape called Circle and Rectangle, as shown in the class diagram.
a) The Circle class contains:
· An instance variable radius (double).
· Three constructors as shown. The no-arg constructor initializes the radius to 1.0.
· Getter and setter for the instance variable radius.
· Methods getArea() and getPerimeter().
· Override the inherited toString() method, to return "A Circle with radius=xxx, which is a subclass of yyy", where yyy is the output of the toString() method from the superclass.
This assignment has 4 sub-sections.
Use the JOptionPane class for all required input/output.
a) Write a superclass called Shape (as shown in the class diagram), which contains:
· Two instance variables color (String) and filled (boolean).
· Two constructors: a no-arg (no-argument) constructor that initializes the color to "green" and filled to true, and a constructor that initializes the color and filled to the given values.
· Getter and setter for all the instance variables. By convention, the getter for a boolean variable xxx is called isXXX() (instead of getXxx() for all the other types).
· A toString() method that returns "A Shape with color of xxx and filled/Not filled".
Write a test program to test all the methods defined in Shape.
Debug and Display the output.
1.
#include
using namespace std;
myFunction() {
cout << "I just got executed!";
}
int main() {
myFunction();
return 0;
}
2.
#include
using namespace std;
void myFunction() {
cout << "I just got executed!\n";
}
int() {
myFunction();
myFunction();
myFunction();
return 0;
}
int i,l,p=0,j; char c; String s,w="",r="";
System.out.println("Enter a String");
s = sc.nextLine(); s = s.trim()+" "; l = s.length();
for (i=0;i<l;i++) {
c = s.charAt(i);
if (c != 32)
w = w + c;
else { p++;
for (j=w.length()-1;j>=0;j--) {
c = w.charAt(j); r = r + c;
} if (w.compareToIgnoreCase(r) == 0 && r.length() > 1)
System.out.println(w+"\t"+p);
w = ""; r = "";
}
if (i == l-1) {
p++;
for (j=w.length()-1;j>=0;j--) {
c = w.charAt(j);
r = r + c;
}
if (w.compareToIgnoreCase(r) == 0 && r.length() > 1)
System.out.println(w+"\t"+p); }}}}
Q. Above coding will display palindrome words along with its position that is where it is present in the String. Add a statement to above coding so that it will display ''No palindrome words found" if there is not a single palindrome word present in the entered String.
write a program to print in D days H hours M minutes S seconds
Create a class Book <BOOK_ID,ISBN,TITLE,PRICE> as member variables. Create functions to read and write Book details.Overload a function SEARCH() to search a book based on ISBN and TITLE.Write a menu driven main(), opting user to key-in the search option as 1.Search by ISBN 2.Search by TITLE.