5
Answers

Method must have a return type?!?

Photo of Jennifer Bell

Jennifer Bell

12y
3.7k
1

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)

0
Photo of Suthish Nair
NA 31.7k 4.6m 14y
Crish, don't post or promote unwanted links here again. We already warned and blocked your user login once. Next time there will be no warning.
0
Photo of Crish
NA 3.7k 76.4k 14y
0
Photo of Rohatash Kumar
NA 25.1k 18.7m 14y
I think

For example, I've an Order table with a DateTime field called OrderDate. I want to retrieve all orders where the order date is equals to 01/01/2006. What's the best way?

  1. WHERE DateDiff(dd, OrderDate, '01/01/2006') = 0
  2. WHERE Convert(varchar(20), OrderDate, 101) = '01/01/2006'
  3. WHERE Year(OrderDate) = 2006 AND Month(OrderDate) = 1 and Day(OrderDate)=1
  4. WHERE OrderDate LIKE '01/01/2006%'
  5. WHERE OrderDate >= '01/01/2006'  AND OrderDate < '01/02/2006'
  6. ...
In my opinion the best way in terms of performances is the 5

WHERE OrderDate >= '01/01/2006'  AND OrderDate < '01/02/2006'

0
Photo of Amit Choudhary
NA 27.7k 3m 14y
hi vishnu,

Use the
DATEDIFF ( datepart , startdate , enddate )
function here the datepart can be days, month or years so you have to mention the days.
and startdate will be date of you have changed your password last time and the end date will be the +30 days of current date.
now you can check it for if 30 days are over or today is last date.

difference the todays date with end date. if the value is +ve then no need to show the link and if its -ve or 0 then show the link for change password.

Hope this make sense to you.


Thanks.