Jennifer Bell

Jennifer Bell

  • NA
  • 14
  • 14.1k

Method must have a return type?!?

Nov 1 2012 2:34 PM

I am getting an error on line 68 Method must have return type. Please help!


using



System;


using



System.Collections.Generic;


using



SC = System.Console;


using



System.Linq;


using



System.Text;



public



class abc


{


   


public static void Main()


    {


       


String continueStr = "Y";


       


double side, length;



       


SC.WriteLine("Lab has started for ");



       


while (continueStr.ToUpper()!="N")


        {


           


SC.Write("\nEnter the value for side ");


            side =


Convert.ToDouble(SC.ReadLine());


           


while (side < 0)


            {


               


SC.WriteLine("The side may not be Negative! Please re-enter");


               


SC.Write("Enter the value for side ");


                side =


Convert.ToDouble(SC.ReadLine());


            }



           


SC.Write("\nEnter the value for length ");


            length =


Convert.ToDouble(SC.ReadLine());


           


while (length < 0)


            {


               


SC.WriteLine("The width may not be Negative! Please re-enter");


               


SC.Write("Enter the value for length ");


                length =


Convert.ToDouble(SC.ReadLine());


            }



           


if (length == 0 && side == 0 )


            {


               


Prism myPrism = new Prism(side, length);


                myPrism.displayData();


            }


           


else (length >= 0 && side >= 0 );


            {


               


Prism myPrism = new Prism(side, length);


                myPrism.displayData();


            }



           


SC.Write("\nWould you like to enter more data (Y/N) ");


            continueStr =


SC.ReadLine();


        }


       


SC.WriteLine("\nLab has successfully terminated for ");


    }


// end of Main method


}


// end of Main class








public



class Square



private double side;     //in a square, both sides are the same


   


public Square ()


    {  


// default constructor


         side = 7;


    }


   


public Square (double s)


    {   side = s;


    }


   


public getSide()           // a getter method


    {  


return side;


    }


   


public double findArea()


    {  


return (side * side);


    }


}                                                                                            


// see the next page for more                                       





public



class Prism : Square


{


   


private double side;


   


private double length;



   


public Prism():base()



    {


        length = 10;


//default constructor


    }



   


public Prism(double s, double l):base(s,l)


    {


        length = l;


// non-default constructor


    }



   


new public double findArea()


    {


       


double squareArea;


        squareArea =


base.findArea();


        getSide =


Math.Sqrt((((5.1 / 2) * (5.1 / 2)) + (9.2 * 9.2)));


       


return Math.Round((2 * squareArea) + (5.1 * 6.7) + (2 * (getSide * 6.7)), 2);


    }


//???



   


public double volume()


    {


       


return Math.findArea() * length ;


    }



   


public void displayData()


    {


       


SC.WriteLine("\nThe side of the Prism is {0,5}",


       


Math.Round(side, 2).ToString("F2"));



       


SC.WriteLine("\nThe length of the Prism is {0,9}",


       


Math.Round(length, 2).ToString("F2"));



    }



   


// code a default constructor, another constructor, a method for the volume,


  


// and a method named findArea() for the surface area; Also code getter method for the length


  


// value and a method named displayData within the Prism class to print the desired output.


}




Answers (5)