// Average.java // import Scanner class using java.util.Scanner import java.util.Scanner; public class Average { //prints average of three numbers public static void main (String[] args) { double...

1 answer below »

// Average.java // import Scanner class using java.util.Scanner  import java.util.Scanner; public class Average {   //prints average  of three numbers    public static void main (String[] args)     {    double num1, num2, num3;    double average;  // create Scanner object     Scanner scan  = new Scanner(System.in);    // Three numbers as inputs are given by user.  // To calculate average.      num1 = scan.nextDouble();     num2 = scan.nextDouble();     num3 = scan.nextDouble();  // We know that average is equal to sum of all  // numbers divided by total number.     average = (num1 + num2 + num3)/3;  // prints the average    System.out.println(average);    } }



NIT2112 – Object-Oriented Programming Semester 1, Block 2, 2021 LAB 1 Assessable Instructions: 1. Check the deadline in VUC. 2. Please submit your source code (.java) file(s) 3. Screen shout for your program and output in a word/pdf file . 3. Any late submission will receive 20% penalty. 4. Marking criteria is as followed:  Completed code according to the task – 10%  No compilation errors – 15%  No runtime errors – 15%  Correct logic to solve the problem – 30%  Correct code formatting, indentations and spacing applied – 10%  Sufficient comments added – 10%  Meaningful names used for variables and methods – 10% Q1. Write program calculate the final price of a purchased item using values entered by the user Hint: you are required to use formatting output for number, currency and percentage. --------------------[Print Receipt] ------------ - Enter the quantity: 6 - Enter the unit price: $1.98 - Subtotals: $10.14 - Tax: $ 0.61 at 6% - Total: $10.75 ------------------------------------------------ Q2. Write a program that prompts for and reads the users’ first name and last name, Job title, DOB (date of Birth), and the Email address (separately). Then create and print a random phone number of the form XXX-XXX-XXXX. Include the dashes in the output. Do not let the first three digits contain an 8 or 9 (but don’t be more restrictive than that), and make sure that the second set of three digits is not greater than 742. Hint: Think through the easiest way to construct the phone number. Each digit does not to be determined separately. ----------------------------[ User details] --------------------- - First name: Adam - Last Name: Hunter - Date of Birth: 20/02/1981 - Email Address: [email protected] - Phone number: 235-653-3541 --------------------------------------------------------------------- Q3. Write a program that reads three integers and prints their average. Q4. Write a program that reads two floating point numbers and prints their sum, difference, and product.
Answered Same DayMar 25, 2021NIT2112

Answer To: // Average.java // import Scanner class using java.util.Scanner import java.util.Scanner; public...

Neha answered on Mar 25 2021
142 Votes
average-hbj0mxf4.java
average-hbj0mxf4.java
import java.util.Scanner;
public class Average {
 pu
blic static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        System.out.print("Enter the first number: ");
        double num1 = scan.nextDouble();
        System.out.print("Enter the second number: ");
        double num2 = scan.nextDouble();
        System.out.print("Enter the third number: ");
        double num3 = scan.nextDouble();
        scan.close();
        double result = (num1 + num2 + num3) / 3;
        System.out.print("The average of entered numbers is:" + result);
    }
}
bill-hhjdqvsl.java
bill-hhjdqvsl.java
import java.util.Scanner;
public class Bill
{
    public static void main(String[] args) { 
        Scanner myObj = new Scanner(System.in); 
        System.out.println("Enter the quantity:");
        int quantity = myObj.nextInt()...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here