Mandy Thompson

Greenhorn
+ Follow
since May 23, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mandy Thompson

In this case, I have to develop a hierarchy and then base my code from that. Since I am new to inheritance, i feel that in this situation, seeing the design prior to starting the coding would benefit me more. I can then take that design and implement it a lot easier.
12 years ago
Dont you think it would be easier to develop the hierarchy tree, realizing the attributes and assigning the instance variables and methods and then start the coding once we can see a layout???
12 years ago
I am having some issues learning inheritance. I have stumbled across this example in my book but it has got me floundered. I am not expecting a resolution to this but maybe a little push in the right direction.

I need to write an inheritance hierarchy for classes quadrilateral, trapezoid, parallelogram, rectangle and square. Quadrilateral bieng the superclass of the heirarchy. Make the hierarchy as deep as possible. Specify the instance variables and methods for each class. The private instance variable of Quadrilateral should be the x-y coordinate pairs for the four ended points fo the Quadrilateral. I then need to write a program that instantiates objects of my classes and outputs each objects area. I am so lost right now so any lead into the right direction would be awesome. Thanks!!
12 years ago
Havnt tested yet, did it at work. What do you think?



import java.io.*;

public class Sales
{
public static void main(String[] args)
{
double total = 0.0;
BufferedReader br = null;
try
{
br = new BufferedReader(
new InputStreamReader(System.in));
boolean readMore = true;
while(readMore)
{
System.out.println("enter product number");
String prodNum = br.readLine();
System.out.println("enter quantity");
String numDesired = br.readLine();
int number, quantity;
try
{
number = Integer.parseInt(prodNum);
quantity = Integer.parseInt(numDesired);
}
catch(NumberFormatException nfe)
{
System.err.println("cannot parse: " + nfe.getMessage());
continue;
}
switch(number)
{
case 1:
total += 2.98 * quantity;
break;
case 2:
total += 4.50 * quantity;
break;
case 3:
total += 9.98 * quantity;
break;
case 4:
total += 4.49 * quantity;
break;
case 5:
total += 6.87 * quantity;
}
System.out.println("order more? 'y' or 'n'");
String decision = br.readLine();
if(!decision.equals("y"))
readMore = false;
}
br.close();
}
catch(IOException ioe)
{
System.err.println("read: " + ioe.getMessage());
}
System.out.println("total cost = " + total);
}
}
13 years ago
I am stuck on this big time, I have been floundering here for like 4 hours and if anyone can help I would be SO grateful, I have this program that I have to write that I cannot grasp. I dont expect anyone to write this for me, maybe some expert guidance or tips is all im asking.

I have to develop a program for a "small company" that sells 5 products with the prices procuct 1 $2.98, product 2 $4.50, product 3 $9.98, product 4 $4.49, and product 5 $6.87. The application has to read in the product number and the quantity sold. The program has to use a switch statement to determine the retail price for each product. It should calculate and display the total retail value of all products sold. It also has to use a sentinel-controlled loop to determine when the program should stop looping and display the final results.

Unfortunately I took this class as an elective and this is my final project. I have looked over this over and over and my book sucks!! Any help from you experts out there would be greatly appreciated. Thanks!
13 years ago