Web Development
Prime Numbers. Write a program that reads in an integer that is greater than 2 (let’s call it k) and finds and prints all of the prime numbers between 3 and k.
LANGUAGE: C++ CHALLENGE: Prime Numbers. Write a program that reads in an integer that is greater than 2 (let’s call it k) and finds and prints all of the prime numbers between 3 and k. A prime number is a number such that 1 and itself are the only numbers that evenly divide it (for…
Read MoreWrite a full class definition for a class named GasTank, and containing the following members
LANGUAGE: C++ CHALLENGE: Write a full class definition for a class named GasTank, and containing the following members: A data member named amount of type double. A constructor that accepts no parameters. The constructor initializes the data member amount to 0. A function named addGas that accepts a parameter of type double. The value of…
Read MoreWrite a statement that declares a prototype for a function twice, which has an int parameter and returns an int.
LANGUAGE: C++ CHALLENGE: Write a statement that declares a prototype for a function twice, which has an int parameter and returns an int.
Read MoreDesign and implement an application that reads a string from the user and prints it one character per line.
LANGUAGE: Java CHALLENGE: Design and implement an application that reads a string from the user and prints it one character per line.
Read MoreDesign and implement a class called Box that contains instance data that represents the height, width, and depth of the box.
LANGUAGE: Java CHALLENGE: Design and implement a class called Box that contains instance data that represents the height, width, and depth of the box. These dimensions should be of a type that can represent linear measurements, including fractional ones. Also include a boolean variable called full as instance data that represents whether the box is…
Read MoreDesign and implement a class called Car that contains instance data that represents the make, model, and year of the car
LANGUAGE: Java CHALLENGE: Design and implement a class called Car that contains instance data that represents the make, model, and year of the car (as a String, String and int value respectively). Define the Car constructor to initialize these values (in that order). Include getter and setter methods for all instance data, and a toString…
Read MoreDesign and implement a class called Sphere that contains instance data that represents the sphere’s diameter.
LANGUAGE: Java CHALLENGE: Design and implement a class called Sphere that contains instance data that represents the sphere’s diameter. Define the Sphere constructor to accept and initialize the diameter, and include getter and setter methods for the diameter. Include methods calcVolume and calcSurfaceArea that calculate and return the volume and surface area of the sphere.…
Read MoreWrite a program that lets the user enter the total rainfall for each of 12 months into an array of doubles.
LANGUAGE: C++ CHALLENGE: Write a program that lets the user enter the total rainfall for each of 12 months into an array of doubles. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts.
Read MoreAssume that an array named salarySteps whose elements are of type int and that has exactly five elements has already been declared.
LANGUAGE: Java CHALLENGE: Assume that an array named salarySteps whose elements are of type int and that has exactly five elements has already been declared. Write a single statement to assign the value 30000 to the first element of this array.
Read MoreGiven Suppose the values of the array a BEFORE your code executed were: 15,7,22,4.
LANGUAGE: Java CHALLENGE: Given Suppose the values of the array a BEFORE your code executed were: 15,7,22,4. Then, AFTER your code executed, the values of the array a would be: 3,7,22,4. Note that the value of the first element was changed to 3. that an array named a with elements of typeint has been declared,…
Read MoreWrite a method, getSecondLine, that is passed a String argument and that returns the second line, without its newline character.
LANGUAGE: Java CHALLENGE: Write a method, getSecondLine, that is passed a String argument and that returns the second line, without its newline character. (Recall that lines are terminated with the “\n” character .) Assume that the argument contains at least two complete, newline-terminated lines.
Read MoreWrite a method, getFirstLine, that is passed a String argument and that returns the first line.
LANGUAGE: Java CHALLENGE: Write a method, getFirstLine, that is passed a String argument and that returns the first line. (Recall that lines are terminated with the “\n” character.) Assume that the argument contains at least one complete, newline-terminated line.
Read More