answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Sloan [31]
2 years ago
12

a. Create an application named NumbersDemo whose main() method holds two integer variables. Assign values to the variables. In t

urn, pass each value to methods named displayTwiceTheNumber(), displayNumberPlusFive(), and displayNumberSquared(). Create each method to perform the task its name implies. Save the application as NumbersDemo.java. b. Modify the NumbersDemo class to accept the values of the two integers from a user at the keyboard. Save the file as NumbersDem02.java.
Computers and Technology
2 answers:
Ilia_Sergeevich [38]2 years ago
5 0

Answer:

PART ONE:

public class NumbersDemo {

   public static void main(String[] args) {

   int num1= 1;

   int num2= 2;

   //Calling method displayTwiceTheNumber()

   displayTwiceTheNumber(num1);

   displayTwiceTheNumber(num2);

   //Calling method displayNumberPlusFive()

   displayNumberPlusFive(num1);

   displayNumberPlusFive(num2);

   //Calling method displayNumberSquared()

   displayNumberSquared(num1);

   displayNumberSquared(num2);

   }

   public static void displayTwiceTheNumber(int num1){

       System.out.println(num1*2);

   }

   public static void displayNumberPlusFive(int num1){

       System.out.println(num1+5);

   }

   public static void displayNumberSquared(int num1){

       System.out.println(num1*num1);

   }

}

PART TWO

import java.util.Scanner;

public class NumbersDem02 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter Values for num1 and num2");

   int num1= in.nextInt();

   int num2= in.nextInt();

   //Calling method displayTwiceTheNumber()

   displayTwiceTheNumber(num1);

   displayTwiceTheNumber(num2);

   //Calling method displayNumberPlusFive()

   displayNumberPlusFive(num1);

   displayNumberPlusFive(num2);

   //Calling method displayNumberSquared()

   displayNumberSquared(num1);

   displayNumberSquared(num2);

   }

   public static void displayTwiceTheNumber(int num1){

       System.out.println(num1*2);

   }

   public static void displayNumberPlusFive(int num1){

       System.out.println(num1+5);

   }

   public static void displayNumberSquared(int num1){

       System.out.println(num1*num1);

   }

}

Explanation:

Three methods are created to do exactly as required by the question

In part two, the scanner class is used to receive the values from the user

aliya0001 [1]2 years ago
3 0
<h2>Answer:</h2>

<h2>(a) </h2>

//Header declaration of class NumbersDemo

public class NumbersDemo {

   //Main method

   public static void main(String[] args) {

       //Declare and initialize the two integer variable

       int fnumber = 23;

       int snumber = 34;

       

       //Call the method displayTwiceTheNumber() using each of the variables above, in turn, as argument

       displayTwiceTheNumber(fnumber);

       displayTwiceTheNumber(snumber);

       

       //Call the method displayNumberPlusFive() using each of the variables above, in turn, as argument

       displayNumberPlusFive(fnumber);

       displayNumberPlusFive(snumber);

       

       //Call the method displayNumberSquared() using each of the variables above, in turn, as argument

       displayNumberSquared(fnumber);

       displayNumberSquared(snumber);

       

   }        // End of main method

   // Declare the method displayTwiceTheNumber() which receives an integer number as argument

   // Its return type is void since it only displays twice the number

   // i.e 2 *  number

   private static void displayTwiceTheNumber(int number) {

       System.out.println("twice of " + number + " : " + 2 * number);

   }

   //Declare the method displayNumberPlusFive() which receives an integer

   // number as argument

   //Its return type is void since it only displays the result when 5 is added

   // to the number i.e number + 5

   private static void displayNumberPlusFive(int number) {

       System.out.println(number + " plus five(5) : " + (number + 5));

   }

   //Declare the method displayTwiceTheNumber which receives an integer

   // number as argument

   //Its return type is void since it only displays the square of the number

   // i.e number * number

   private static void displayNumberSquared(int number) {

       System.out.println(number + " squared : " + (number*number));

   }

   

}      // End of class declaration

<h2>(b)</h2><h2 />

//import the Scanner class

import java.util.Scanner;

//Header declaration of class NumbersDemo 02

public class NumbersDemo02 {

   //Main method

   public static void main(String[] args) {

       

       //create an object of the Scanner class to allow for user's input

       Scanner input = new Scanner(System.in);

       

       //prompt user to enter first number;

       System.out.println("Please enter first number");

       

       //Declare and initialize an integer variable to hold the first number

       int fnumber = input.nextInt();

       

       //prompt user to enter second number;

       System.out.println("Please enter second number");

       

       //Declare and initialize an integer variable to hold the first number

       int snumber = input.nextInt();

       

       //Call the method displayTwiceTheNumber() using each of the

       // variables above, in turn, as argument

       displayTwiceTheNumber(fnumber);

       displayTwiceTheNumber(snumber);

       

       // Call the method displayNumberPlusFive() using each of the variables

       // above, in turn, as argument

       displayNumberPlusFive(fnumber);

       displayNumberPlusFive(snumber);

       

       // Call the method displayNumberSquared() using each of the variables

       // above, in turn, as argument

       displayNumberSquared(fnumber);

       displayNumberSquared(snumber);

       

   }

   //Declare the method displayTwiceTheNumber() which receives an

   // integer number as argument

   //Its return type is void since it only displays twice the number

   // i.e 2 * number

   private static void displayTwiceTheNumber(int number) {

       System.out.println("twice of " + number + " : " + 2 * number);

   }

   //Declare the method displayNumberPlusFive() which receives an integer    

   // number as argument

   //Its return type is void since it only displays the result when 5 is added

   // to the number i.e number + 5

   private static void displayNumberPlusFive(int number) {

       System.out.println(number + " plus five(5) : " + (number + 5));

   }

   //Declare the method displayTwiceTheNumber which receives an integer

   // number as argument

   //Its return type is void since it only displays the square of the number

   // i.e number * number

   private static void displayNumberSquared(int number) {

       System.out.println(number + " squared : " + (number*number));

   }

   

}    // End of class declaration

<h2>Sample Output to (a):</h2>

twice of 23 : 46

twice of 34 : 68

23 plus five(5) : 28

34 plus five(5) : 39

23 squared : 529

34 squared : 1156

<h2>Sample Output to (b):</h2>

>> Please enter first number

12

>> Please enter second number

23

twice of 12 : 24

twice of 23 : 46

12 plus five(5) : 17

23 plus five(5) : 28

12 squared : 144

23 squared : 529

<h2>Explanation:</h2>

The above codes have been written in Java and it contains comments explaining every part of the code. Please go through the comments for explanation.

You might be interested in
A distribution of software that simplifies administration by identifying dependencies, automatically updating configuration file
emmasim [6.3K]

Answer:

Package

Explanation:

In a conventional kind of definition, a software package is basically several applications or code modules that work hand-in-hand to meet a range of goals and objectives. One of the most well-known examples is package like the Microsoft Office package, which consist of individual applications such as Excel, Word, Access and PowerPoint.

It can also be said to be numerous individual files or resources that are packed together as a software set which is meant to provides specific functionality as part of a larger system.

6 0
2 years ago
In this assignment, you will develop a C++ program and a flowchart that calculates a cost to replace all tablets and desktop com
Alexeev081 [22]

Answer:

Explanation:

The objective of this program we are to develop is to compute a C++ program and a flowchart that calculates a cost to replace all tablets and desktop computers in a business.

C++ Program

#include<iostream>

#include<iomanip>

using namespace std;

/*

⦁ // Name:

⦁ // Date:

⦁ // Program Name:

⦁ // Description:

*/

int main()

{

const double SalesTaxRate = .075, DiscountPercent = .10, FinanceCharge = .15;

const double TABLET = 320.00, DESKTOP = 800.00;

double total = 0.0, subTotal = 0.0,avg=0.0;

int numberOfTablets, numberOfDesktop;

cout << "-------------- Welcome to Computer Selling Company ------------------ ";

cout << "Enter number of tablets: ";

cin >> numberOfTablets;

cout << "Enter number of desktops: ";

cin >> numberOfDesktop;

subTotal = TABLET * numberOfTablets + numberOfDesktop * DESKTOP;

char choice;

cout << "Paying cash or financing: (c/f): ";

cin >> choice;

cout << fixed << setprecision(2);

if (choice == 'c' || choice == 'C')

{

cout << "You have choosen paying cash." << endl;

total = subTotal - subTotal * DiscountPercent;

cout << "Discount you get $" << subTotal * DiscountPercent<<endl;

cout << "Sales Tax: $" << SalesTaxRate * total << endl;

total = total + total * SalesTaxRate;

cout << "Total computers' Cost: $" << total << endl;

avg = total / (numberOfDesktop + numberOfTablets);

cout << "Average computer cost: $ " << avg << endl;

}

else if (choice == 'f' || choice == 'F')

{

cout << "You have choosen Finance option." << endl;

total = subTotal + subTotal * FinanceCharge;

cout << "Finance Charge $" << subTotal * FinanceCharge << endl;

cout << "Sales Tax: $" << SalesTaxRate * total << endl;

total = total + total * SalesTaxRate;

cout << "Total computers' Cost: $" << total << endl;

avg = total / (numberOfDesktop + numberOfTablets);

cout << "Average computer cost: $ " << avg << endl;

}

else

{

cout << "Wrong choice.......Existing.... ";

system("pause");

}

//to hold the output screen

system("pause");

} }

OUTPUT:

The Output of the program is shown in the first data file attached below:

FLOWCHART:

See the second diagram attached for the designed flowchart.

5 0
2 years ago
(1) Prompt the user to enter five numbers, being five people's weights. Store the numbers in an array of doubles. Output the arr
Mashutka [201]

Answer:

weights = []

total = 0

max = 0

for i in range(5):

   weight = float(input("Enter weight " + str(i+1) + ": "))

   weights.append(weight)

   total += weights[i]

   if weights[i] > max:

       max = weights[i]

average = total / 5

print("Your entered: " + str(weights))

print("Total weight: " + str(total))

print("Average weight: " + str(average))

print("Max weight: " + str(max))

Explanation:

Initialize the variables

Create a for loop that iterates 5 times

Get the values from the user

Put them inside the array

Calculate the total by adding each value to the total

Calculate the max value by comparing each value

When the loop is done, find the average - divide the total by 5

Print the results

6 0
2 years ago
Jim is writing a program to calculate the wages of workers in a teddy bear factory.
34kurt

Answer:

The algorithm is as follows;

1. Start

2. Input TeddyBears

3. Input Hours

4. WagebyTeddy = 2 * TeddyBears

5. WagebyHour = 5 * Hours

6. If WagebyHour > WagebyTeddy then

6.1 Print WagebyHour

7. Else

7.1. Print WagebyTeddy

8. Stop

Explanation:

The following variables are used;

TeddyBears -> Number of teddy bears made

Hours -> Number of Hours worked

WagebyTeddy -> Wages for the number of teddy bears made

WagebyHour -> Wages for the number of hours worked

The algorithm starts by accepting input for the number of teddy bears and hours worked from the user on line 2 and line 3

The wages for the number of teddy bears made  is calculated on line 4

The wages for the number of hours worked  is calculated on line 5

Line 6 checks if wages for the number of hours is greated than wages for the number of bears made;

If yes, the calculated wages by hour is displayed

Otherwise

the calculated wages by teddy bears made is displayed

3 0
2 years ago
The president of the company wants a list of all orders ever taken. He wants to see the customer name, the last name of the empl
blsea [12.9K]

Answer:

see explaination

Explanation:

Check the SQL query below:

SELECT c.CustomerName, e.LastName, s.ShipperName, p.ProductName, o.Quantity, od.OrderDate

FROM

Customers c, Employee e, Shippers s, Orders o, OrderDetails od, Product p

WHERE c.customerID = o.customerID AND

e.employeeID = o.employeeID AND

o.orderID = od.orderID AND

od.shipperID = s.shipperID AND

od.productID = p.productID;

6 0
2 years ago
Other questions:
  • Lukas entered the date 9-17-2013 in an Excel workbook. He wants the date to appears as “Tuesday, September 17, 2013.” Instead of
    12·1 answer
  • Mark T for True and F for False. No single person or government agency controls or owns the Internet. The W3C is responsible for
    5·1 answer
  • Strlen("seven"); what is the output?
    14·1 answer
  • _______________ is used by a hacker to mask intrusion and obtain administrator permissions to a computer.
    7·1 answer
  • Our company is only interested in purchasing a software upgrade if it leads to faster connectivity and data sharing. The old sof
    7·1 answer
  • Your southern region is not doing very well. You want to know why, so you ask for a special report showing the numbers for the s
    15·1 answer
  • Chris accidentally steps on another student’s foot in the hallway. He apologizes, but the other student does not want to hear it
    13·2 answers
  • Which among the following enhances WS-Security to facilitate a mechanism for issuing, renewing, and validating security tokens?
    13·1 answer
  • Choose the reasons why Windows Server operating systems are a popular choice for a network because they _____. Select all that a
    12·1 answer
  • 4.2 Code Practice: Question 2
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!