PROJECT ANS
Project 1
This program calculates number of months needed for bunnies to reach a total of 100 and 1000 respectively
Declare n as integer “Number is the initial number ”
Input the number
Declare monthsCounter as integer
Set MonthsCounter to zero
Set total to n
WHILE newTotal is less than 100:
Set total to double the total
Increase monthsCounter by three
ENDWHILE
PRINT “The initial number of bunnies :”+n
PRINT “It takes monthsCounter months to reach to 100”
Set MonthsCounter to zero
Set newTotal to n
WHILE total is less than 1000:
Set total to double the total
Increase monthsCounter by three
ENDWHILE
PRINT “It takes monthsCounter months to reach to 1000”
Project 2
/**
*This program computes the volume in gallons and weight in
*pounds for water used to fill balloons toss contest
*
*/
public class NewClass {
public static void main(String[] args) {
//Declare and initialize variables
Scanner scan = new Scanner(System. in );
final double INCHES_CUBED_TO_GALLON = 231;
final double GALLON_TO_POUNDS = 8.33;
int balloons; //number of balloons
double diameter; //diameter of balloon in inches
double volume = 0; //volume in inches cubed
double volumeInGallons; //volume in gallons
double weight; //weight in pounds
//get inputs
System. out .print("Number of water balloons: ");
balloons = scan.nextInt();
System. out .print("Diameter of each balloon in inches: ");
diameter = scan.nextDouble();
//Do calculations
volume = balloons * 3 / 4 * Math. PI * Math.pow((diameter / 2), 3);
volumeInGallons = volume / INCHES_CUBED_TO_GALLON;
weight = volumeInGallons * GALLON_TO_POUNDS;
//display the output
System. out .println("\nWater balloon information");
System. out .println("Number of balloons= " + balloons);
System. out .println("Gallon of water needed to fill up the balloons= "
+ volumeInGallons + " Gallons");
System. out .println("Total weight= " + weight + " Pounds");
}//end of main function
}//end of class