The first class represents a student and must be named using your first and last name.

3 Marks

Learning Outcome(s):

Develop a program based on specification using programming language elements including syntax, data types, conditional statement, control structures, procedures, arrays, objects and classes.

 

 

 

 

 

 

 

Question One

Write a complete Java program that performs the following tasks:

  1. Ask the user to enter his/her full name and print a welcome message using the user’s name.
  2. Ask the user to enter any city.
  3. Ask the user to enter the weather temperature.
  4. Ask the user to enter 1 or 2 to choose the type of conversion.
  5. Write two methods that should take a city and a temperature as arguments, and print the Celsius or Fahrenheit equivalent, using the following calculations:

Celsius = 5.0 ÷ 9.0 × (Fahrenheit – 32)

Fahrenheit = 9.0 ÷ 5.0 × Celsius + 32

Each method will be called based on the user choice. For example,

  • if the user enters 1, the method that calculates and prints Celsius is invoked
  • if the user enters 2, the method that calculates and prints Fahrenheit is invoked.

Note:

  • The class name of your Java program must be your first name.
  • Your answer should have the code as text as well as the screenshot of the program output (using your own name) as a part of your answer. Otherwise, zero marks will be awarded.

Typical runs of the program

2 Marks

Learning Outcome(s):

Develop a program based on specification using programming language elements including syntax, data types, conditional statement, control structures, procedures, arrays, objects and classes.

 

 

 

 

 

 

Question Two

Write a complete Java program that performs the following tasks:

  1. Create and initialize an array named studID with 9 elements. The array must be initialized with your student id. For example, if your student ID is 123456749, you need to take each single digit as the elements of your array.
  2. Print the elements of the array using enhanced for loop.
  3. Asks the user to give a number between 1 and 9 and save it in a variable num.
  4. In the array studID, find and print the following:
  • Count the numbers divisible by num
  • Number of even numbers that is less than num
  • Number of odd numbers that is less than num
  • The sum of all numbers that are divisible by 3 or by 4.

Note:

  • The class name of your Java program must be your first name.
  • Your answer should have the code as text as well as the screenshot of the program output (using your own student ID) as a part of your answer. Otherwise, zero marks will be awarded.

Typical run of the program

 

 

 

 

 

3 Marks
Learning Outcome(s):

Explain the basic principles of programming, concept of language, and universal constructs of programming languages.

 

 

 

 

 

 

Question Three

Write a complete Java program as follow:

  1. Create two java classes:
    1. The first class represents a student and must be named using your first and last name.
    2. The second class must be named as “Main” with the main method.
  2. Perform the following in the first class:
    1. Create three private instance variables to store first name, last name and GPA. Do not assign any values to the variables in this step!
    2. Create a constructer without parameters to initialize all the instance variables to default values (0 for numbers and “” for a string).
    3. Create a constructor that can take the first and last name as parameters. Assign the parameters’ values to the two instance variables you created earlier (first and last name).
    4. Create a getName() method to return the first and last name. You must return the first and last name in a single string using a plus sign. You must have a space between the first name and last name.
    5. Create setGPA() and getGPA() methods to store and return your GPA, respectively.
  3. Perform the following in the main class:
    1. Create a new object of your first class and pass your first and last name as two parameters.
    2. Call the getName() method and store the result in a string variable called myFullName.
    3. Print your full name using the string variable myFullName.
    4. Set your GPA using the setGPA()
    5. Print your GPA using the getGPA()

 

Note:

  • Your answer should have the code as text as well as the screenshot of the program output (using your own name) as a part of your answer. Otherwise, zero marks will be awarded.

Typical run of the program

 

 

 

 

 

 

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more
error: Content is protected !!