How do I reset another set of output?

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Dec 2008
Posts: 65
Reputation: StarZ is an unknown quantity at this point 
Solved Threads: 1
StarZ StarZ is offline Offline
Junior Poster in Training

How do I reset another set of output?

 
0
  #1
Oct 8th, 2009
I've got the codes all done;
so its looks like this:

  1. public class RightTriangle {
  2.  
  3. public static void main(String[] args) {
  4. Triangle shape = new Triangle();
  5.  
  6. shape.setBase(4.0);
  7. shape.setHeight(5.0);
  8.  
  9.  
  10. System.out.println("The base of the right triangle is " + shape.getBase());
  11. System.out.println("The height of the right triangle is " + shape.getHeight());
  12. System.out.println("The area of the right triangle is " + shape.area());
  13. }
  14. }

and the other file is:
  1. public class Triangle {
  2. private double base;
  3. private double height;
  4.  
  5.  
  6. public Triangle() {
  7. base = 4.0;
  8. }
  9.  
  10. public void setHeight(double newHeight) {
  11. height = newHeight;
  12. }
  13.  
  14. public void setBase(double newBase) {
  15. base = newBase;
  16. }
  17.  
  18. public double area() {
  19. double triangleArea;
  20.  
  21. triangleArea = 0.5 * base * height;
  22. return(triangleArea);
  23. }
  24.  
  25.  
  26. public double getHeight() {
  27. return(height);
  28. }
  29.  
  30. public double getBase() {
  31. return(base);
  32. }
  33. }

How/what code(s) do I use to output another set of statements. like right now this program will output:
The base of the right triangle is 4.0
The height of the right triangle is 5.0
The area of the right triangle is 10.0


but then I want it in the same file another output saying:
The NEW base of the right triangle is ...
the NEW height of the right triangle is ...


Like what's that code where I can "reset" the base and heights.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 160
Reputation: snippsat is an unknown quantity at this point 
Solved Threads: 48
snippsat snippsat is offline Offline
Junior Poster
 
1
  #2
Oct 8th, 2009
DaniWeb Community > Software Development > Python
So why are you posting java code here?
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 65
Reputation: StarZ is an unknown quantity at this point 
Solved Threads: 1
StarZ StarZ is offline Offline
Junior Poster in Training
 
0
  #3
Oct 9th, 2009
oh.. oops...
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC