# Main Blog Directory

Something Cool

## Assign the sum you compute to a variable q For example, if h is 19, you would assign 4 to q because there are perfect squares (starting with 1 ) that are less than h are: 1 , 4 , 9 , 16.

LANGUAGE:  PYTHON CHALLENGE: Assume there is a variable, h already associated with a positive integer value. Write the code necessary to count the number of perfect squares whose value is less than h, starting with 1. (A perfect square is an integer like 9 , 16 , 25 , 36 that is equal to the […]

## Assume there is a variable, h already associated with a positive integer value.

LANGUAGE:  PYTHON CHALLENGE: Assume there is a variable, h already associated with a positive integer value. Write the code necessary to compute the sum of the perfect squares whose value is less than h, starting with 1. (A perfect square is an integer like 9 , 16 , 25 , 36 that is equal to […]

## Assume the existence of a Widget class that implements the Comparable interface and thus has a compareTo method that accepts an Object parameter and returns an int. Write an efficient static method, getWidgetMatch, that has two parameters.

LANGUAGE: JAVA CHALLENGE: Assume the existence of a Widget class that implements the Comparable interface and thus has a compareTo method that accepts an Object parameter and returns an int. Write an efficient static method, getWidgetMatch, that has two parameters. The first parameter is a reference to a Widget object. The second parameter is a potentially […]

## Given that an array of int named a has been declared, and that the integer variable n contains the number of elements of the array a, assign -1 (minus one) to the last element in a.

LANGUAGE: C++ CHALLENGE: Given that an array of int named a has been declared, and that the integer variable n contains the number of elements of the array a, assign -1 (minus one) to the last element in a.

## Write a program class named SquareDisplay that asks the user for a positive integer no greater than 15.

LANGUAGE: JAVA CHALLENGE: 19. Squares. Write a program class named SquareDisplay that asks the user for a positive integer no greater than 15. The program should then display a square on the screen using the character ‘X’. The number entered by the user will be the length of each side of the square. For example, if […]

## Write the definition of a function printDottedLine, which has no parameters and doesn’t return anything.

LANGUAGE: C++ CHALLENGE: Write the definition of a function printDottedLine, which has no parameters and doesn’t return anything. The function prints to standard output a single line (terminated by a new line character) consisting of 5 periods.

## Design a class called Date that has integer data members to store month, day, and year. The class should have a three-parameter (day-of-month, month, year) default constructor that allows the date to be set at the time a new Date object is created.

LANGUAGE: C++ CHALLENGE: Design a class called Date that has integer data members to store month, day, and year. The class should have a three-parameter (day-of-month, month, year) default constructor that allows the date to be set at the time a new Date object is created. If the user creates a Date object without passing any […]

## Write a full class definition for a class named Averager, and containing the following members: An data member named sum of type integer. An data member named count of type integer.

LANGUAGE: C++ CHALLENGE: Write a full class definition for a class named Averager, and containing the following members: An data member named sum of type integer. An data member named count of type integer. A constructor with no parameters. The constructor initializes the data members sum and the data member count to 0. A function named […]

## Clunker Motors Inc. is recalling all vehicles from model years 2001-2006. A boolean variable named recalled has been declared. Given a variable modelYear write a statement that assigns true to recalled if the value of modelYear falls within the recall range and assigns false otherwise.

LANGUAGE: Java CHALLENGE: Clunker Motors Inc. is recalling all vehicles from model years 2001-2006. A boolean variable named recalled has been declared. Given a variable modelYear write a statement that assigns true to recalled if the value of modelYear falls within the recall range and assigns false otherwise. Do not use an if statement in this […]

## Why is Mexico City especially vulnerable to earthquakes?

1

QUESTION: Why is Mexico City especially vulnerable to earthquakes?

## Write an if/else statement that adds 1 to the variable minors if the variable age is less than 18, adds 1 to the variable adults if age is 18 thorugh 64, and adds 1 to the variable seniors if age is 65 or older.

LANGUAGE: Visual Basic CHALLENGE:  Write an if/else statement that adds 1 to the variable minors if the variable age is less than 18, adds 1 to the variable adults if age is 18 thorugh 64, and adds 1 to the variable seniors if age is 65 or older.

## Online Book Merchants offers premium customers 1 free book with every purchase of 5 or more books and offers 2 free books with every purchase of 8 or more books.  It offers regular customers 1 free book with every purchase of 7 or more books, and offers 2 free books with every purchase of 12 or more books.  Write a statement that assigns free Books the appropriate value based on the values of the bool variable is Premium Customer and the int variable n books Purchased

LANGUAGE: Visual Basic CHALLENGE: Online Book Merchants offers premium customers 1 free book with every purchase of 5 or more books and offers 2 free books with every purchase of 8 or more books.  It offers regular customers 1 free book with every purchase of 7 or more books, and offers 2 free books with every […]