please any help with this homework

IMPORTANT: Use Techniques Learned in Chapeters 1 – 5 only

Problem # 1 (Points):

Write a JPanel class named OlympicsLogo which displays the Olympics logo as shown. The OlympicsLogo has one instant variable – diameter (type int). The diameter value must be an even number between 20 and 200. If diameter is set to invalid value, the class must reset it to a default value of 100. Write a default constructor OlympicsLogo() which initializes diameter to its default value. Write another constructor OlympicsLogo(int d) which initializes diameter to d if it is a valid value. Write a method setDiameter(int d) that sets the value of diameter. Use paintComponent() method to draw. The dimensions must be according to the shown figure (for example, 4 means that the distance is four pixels).

Write a test application to demostrate the class OlympicsLogo. The test application will ask the user for the diameter and then use it to display OlympicsLogo inside a JFrame of dimensions 700 x 700.

Problem # 2 (Points):

Write a class named Logic which includes two instant variables - (binnumber1 of type int) and (binnumber2 of type int). The variables binnumber1 and binnumber2 will represent an 8-bit binary numbers. DO NOT define any constructor, but write a set method for each instant variable. The set methods must check that the numbers entered are valid 8-bit binary numbers; otherwise the set methods must keep the instant variables’ current value. Provide the following four methods:
int getAND() – returns the number resulted from operation (binnumber1 AND binnumber2)
int getOR() – returns the number resulted from operation (binnumber1 OR binnumber2)
int getNOT1 () – returns the number resulted from operation (NOT binnumber1)
int getNOT2 () – returns the number resulted from operation (NOT binnumber2)

Write an application that demonstrates the class Logic. The application will continously ask the user for two 8-bit binary numbers and then use the class Logic to display the results of AND, OR and NOT operations on these two numbers. If the user entered -1 for the first number, the application should terminate.


Problem #3 (Points):

A campany sells 6 products whose prices are as follow: P1, $10.00; P2, $5.00; P3, $2.25; P4, $15.65; P5, $42.75; and P6, $24.35. Write an application the reads a series of pairs as follows:
a) Product Number
b) Quantity Sold
The application should use a switch statement to determine the price for each product. It should calculate and display the total retail value of all products sold. Use a sentinel-controlled loop to determine when the application should stop the loop and display the final results. (Note: Use classes)


Problem #4 (Points):
Calculate the value f π from the infinite series
Π = 4 – 4/3 + 4/5 -4/7 +4/9 – 4/11+…
Print a table that shows the value of π approximated by computing the first 200,000 terms of this series. How many terms do you have to use before ou first get a value that begins with 3.14159. (Note: Use classes)


Problem #5 ( Points):

Write a class application that draws the picture below. You need to Name this as class Face.

You picture should be controlled by several constants (all measures are in inches):
HeadRadius = 1.0;
double StemWidth = 0.1;
double StemHeight = 0.15;
double EyeWidth = 0.3;
double EyeHeight = 0.2;
double NoseWidth = 0.2;
double NoseHeight = 0.2;
int NTeethPerRow = 7;
double ToothWidth = 0.083333;
double ToothHeight = 0.15;

These values are the ones used to produce the face shown, and you should be able to figure out what each constant means by looking at the picture. Your application must be written so that changing any of these constants changes the picture in the appropriate way. For example, if you change NTeethPerRow to 4, the new diagram should have only four teeth in each row, but the mouth should still be centered horizontally. The two eyes and the mouth of the face should be drawn halfway from the center to the edge of the circle in the appropriate direction, so that changing HeadRadius also changes the positions at which these features are drawn. The center of the circle representing the pumpkin should appear at the center of the screen. Note: please feel free to add additional control components and color the different parts of the pumpkin face to spice up the program.
Important: to make grading easier, please make sure that the width and height of your window form are no larger than 600 and 500 respectively.
Hint: Once again, it would be useful to use decomposition to split the work of drawing the entire face into smaller methods.

Okay? And your question is? Just so you know, we are not going to do it for you.

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.