Main Blog Directory

Something Cool

Create a PrintStream object using dos and assign the resulting reference to ps, a PrintStream variable that has already been declared.

Create a PrintStream object using dos and assign the resulting reference to ps, a PrintStream variable that has already been declared.

LANGUAGE:  JAVA CHALLENGE: One of the constructors for PrintStream class has a single OutputStream argument. Assume that dos is a variable that references an OutputStream object. Create a PrintStream object using dos and assign the resulting reference to ps, a PrintStream variable that has already been declared.

Read More

Assume that name is a variable of type String that has been assigned a value. Write an expression whose value is a String containing the last character of the value of name. So if the value of name were “Smith” the expression’s value would be “h”.

Assume that name is a variable of type String that has been assigned a value.  Write an expression whose value is a String containing the last character of the value of name.  So if the value of name were “Smith” the expression’s value would be “h”.

LANGUAGE:  JAVA CHALLENGE: Assume that name is a variable of type String that has been assigned a value. Write an expression whose value is a String containing the last character of the value of name. So if the value of name were “Smith” the expression’s value would be “h”.

Read More

Assume that name has been declared suitably for storing names (like “Amy”, “Fritz” and “Moustafa”)

Assume that name has been declared suitably for storing names (like “Amy”, “Fritz” and “Moustafa”)

LANGUAGE:  JAVA CHALLENGE: Assume that name has been declared suitably for storing names (like “Amy”, “Fritz” and “Moustafa”). Assume also that stdin is a variable that references a Scanner object associated with standard input. Write some code that reads a value into name then prints the message “Greetings, NAMEVALUE!!!” on a line by itself where […]

Read More

Suppose a reference variable of type File called myFile has already been declared. Create an object of type File with the initial file name input.dat and assign it to the reference variable myFile.

Suppose a reference variable of type File called myFile has already been declared. Create an object of type File with the initial file name input.dat and assign it to the reference variable myFile.

LANGUAGE:  JAVA CHALLENGE: Suppose a reference variable of type File called myFile has already been declared. Create an object of type File with the initial file name input.dat and assign it to the reference variable myFile.

Read More

Given an integer variable i and a floating-point variable f, that have already been given values, write a statement that writes both of their values to standard output in the following format

Given an integer variable i and a floating-point variable f, that have already been given values, write a statement that writes both of their values to standard output in the following format

LANGUAGE:  JAVA CHALLENGE: The exercise instructions here are LONG — please read them all carefully. If you see an internal scrollbar to the right of these instructions, be sure to scroll down to read everything. Given an integer variable i and a floating-point variable f, that have already been given values, write a statement that […]

Read More

Write a program that takes the account’s present value, monthly interest rate, and the number of months that the money will be left in the account as three inputs from the user.

Write a program that takes the account’s present value, monthly interest rate, and the number of months that the money will be left in the account as three inputs from the user.

LANGUAGE:  PYTHON CHALLENGE: Suppose you have a certain amount of money in a savings account that earns compound monthly interest, and you want to calculate the amount that you will have after a specific number of months. The formula is as follows: f = p * (1 + i)^t • f is the future value […]

Read More

Write a Boolean function named is_prime which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise. Use the function in a program that prompts the user to enter a number and then prints whether the number is prime.

Write a Boolean function named is_prime which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise. Use the function in a program that prompts the user to enter a number and then prints whether the number is prime.

LANGUAGE:  PYTHON CHALLENGE: A prime number is a number that is only evenly divisble by itself and 1. For example, the number 5 is prime because it can only be evenlly divided by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 2 and 3. Write a […]

Read More