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
sukhopar [10]
2 years ago
10

Print "userNum1 is negative." if userNum1 is less than O. End with newline Convert userNum2 to 0 if userNum2 is greater than 8.

Otherwise, print "userNum2 is less than or equal to 8.. End with newline. 1 public class UserNums 2public static void main (String args) int userNum1; int userNum2 userNumt - -1; userNum2 7; Your solution goes here / 10 System.out.printin("userNum2 is "userNum2);
Computers and Technology
1 answer:
Butoxors [25]2 years ago
8 0

Answer:

import java.util.Scanner;

public class num1 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter User name 1 and 2");

       int userNum1 = in.nextInt();

       int userNum2= in.nextInt();

       if(userNum1<0){

           System.out.println("userNum1 is negative.");

       }

       else if(userNum2>8){

           userNum2 =0;

       }

       else{

           System.out.println("userNum2 is less than or equal to 8..");

       }

   }

}

Explanation:

This is implemented in Java programming language

Using the scanner class, the user is prompted to enter two numbers

These are saved in the variable userNum1 and userNum2 respectively.

If, else if and else statements are then used according to the specifications given in the question.

You might be interested in
add is a method that accepts two int arguments and returns their sum. Two int variables, euroSales and asiaSales, have already b
Oduvanchick [21]

Answer:

// here is code in Java.

// package

import java.util.*;

// class definition

class Main

{

   // method that return sum of two sale value

   public static int Add(int euroSales,int asiaSales)

   {

       // return the sum

       return euroSales+asiaSales;

   }

   //main method of the class

public static void main (String[] args) throws java.lang.Exception

{

   try{

    // variables

       int euroSales=100;

       int asiaSales=150;

       int eurasiaSales;

        // call the function

       eurasiaSales=Add(euroSales,asiaSales);

        // print the sum

       System.out.println("total sale is:"+eurasiaSales);

   }catch(Exception ex){

       return;}

}

}

Explanation:

Declare and initialize two variables "euroSales=100" and "asiaSales=150". Declare another variable eurasiaSales. Call the method Add() with euroSales and asiaSales as parameter. This method will add both the value and return the sum.This sum will be assigned to variable eurasiaSales.Then print the sum.

Output:

total sale is:250  

8 0
2 years ago
If the object instance is created in a user program, then the object instance can access both the public and private members of
rewona [7]

Answer:

False

Explanation:

The private member of a class is not accessible by using the Dot notation ,however the private member are those which are not accessible inside the class they are accessible outside the class  .The public member are accessible inside the class so they are accessible by using the dot operator .

<u>Following are the example is given below in C++ Language </u>

#include<iostream>   // header file

using namespace std;  

class Rectangle

{    

   private:  

       double r; // private member  

   public:      

       double  area()  

       {     return 3.14*r*r;  

       }        

};  

int main()  

{    

  Rectangle r1;// creating the object  

   r1.r = 3.5;  

 double t= r1.area(); // calling

cout<<" Area is:"<<t;  

   return 0;  

}  

Output:

compile time error is generated

<u>The correct program to access the private member of class is given below </u>

#include<iostream>   // header file

using namespace std;  

class Rectangle

{    

   private:  

       double r; // private member  

   public:      

       double  area()  

       {    

r1=r;

double t2=3.14*r2*r2;

return(t2); // return the value  

       }        

};  

int main()  

{    

  Rectangle r1;// creating the object  

   r1.r = 1.5;  

 double t= r1.area(); // calling

cout<<" Area is:"<<t;  

   return 0;  

}  

Therefore the given statement is False

5 0
2 years ago
The establishment called ABC Enterprise requires a Java program to keep a database of the inventory of the products that it sell
Alexandra [31]

Answer:

// GetData.java

import javax.swing.JOptionPane;

public class GetData

{

  public static double getDouble(String s)

  {

      return Double.parseDouble(getWord(s));

  }

  public static int getInt(String s)

  {

      return Integer.parseInt(getWord(s));

  }

  public static String getWord(String s)

  {

      return JOptionPane.showInputDialog(s);

  }

  public static String getString(String s)

  {

      return JOptionPane.showInputDialog(s);

  }

}

// Address.java

public class Address

{

  private String street, city, state, zip;

  public Address(String str, String city, String st, String zip)

  {

      street = str;

      this.city = city;

      state = st;

      this.zip = zip;

  }

  public String getStreet()

  {

      return street;

  }

 

  public String getCity()

  {

      return city;

  }

  public String getState()

  {

      return state;

  }

  public String getZip()

  {

      return zip;

  }

}

// Manufacturer.java

public class Manufacturer

{

  private String companyName;

  private Address companyAddress;

 

  public Manufacturer()

  {

      this.companyName = "";

      this.companyAddress = null;

  }

 

  public Manufacturer(String compName, Address address)

  {

      this.companyName = compName;

      this.companyAddress = address;

  }

 

  public String getCompanyName()

  {

      return companyName;

  }

 

  public void setCompanyName(String companyName)

  {

      this.companyName = companyName;

  }

 

  public Address getCompanyAddress()

  {

      return companyAddress;

  }

 

  public void setCompanyAddress(Address address)

  {

      this.companyAddress = address;

  }

}

// Product.java

import java.text.SimpleDateFormat;

import java.util.Date;

public class Product

{

 

  SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");

 

 

  Manufacturer manufacture;

 

 

  String productName;

 

 

  int quantity;

 

 

  double unitPrice;

 

 

  Date productCreated;

 

 

  public Product()

  {

      this.productName = "";

      this.quantity = 0;

      this.unitPrice = 0.0;

      this.productCreated = null;

      this.manufacture = null;

  }

 

  public Product(String prodName, int quantity, double unitPrice,

                        Date productCreated, Manufacturer manufact)

  {

      this.productName = prodName;

      this.quantity = quantity;

      this.unitPrice = unitPrice;

      this.productCreated = productCreated;

      this.manufacture = manufact;

  }

 

 

  public Date getProductCreated()

  {

      return productCreated;

  }

 

 

  public void setProductCreated(Date productCreated)

  {

      this.productCreated = productCreated;

  }

 

  // to get the Manufacturer object

  public Manufacturer getManufacture()

  {

      return manufacture;

  }

 

  // to set the Manufacturer object

  public void setManufacture(Manufacturer manufacture)

  {

      this.manufacture = manufacture;

  }

 

  // to get the name of the product

  public String getProductName()

  {

      return productName;

  }

 

  // to set the name of the product

  public void setProductName(String prodName)

  {

      this.productName = prodName;

  }

 

  // to get the quantity of the product

  public int getQuantity()

  {

      return quantity;

  }

 

  // to set the quantity of the product

  public void setQuantity(int quantity)

  {

      this.quantity = quantity;

  }

 

  // to get the unit price of the product

  public double getUnitPrice()

  {

      return unitPrice;

  }

 

  // to set the unit price of product

  public void setUnitPrice(double unitPrice)

  {

      this.unitPrice = unitPrice;

  }

 

  // to update the quantity of the product

  public void upDateQuantity(int quantity_upDate)

  {

      quantity += quantity_upDate;

  }

 

  // to update the price of the product

  public void upDatePrice(double price_upDate)

  {

      this.unitPrice = price_upDate;

  }

 

 

  public String getProductInfomation()

  {

      String result = "";

      result += String.format("%-30s", productName);

      String dateForm = sdf.format(productCreated);

      result += String.format("\t %s", dateForm);

      result += String.format("%10d", quantity);

      result += String.format("\t%15.2f", unitPrice);

      result += String.format("\t%15s",

                          manufacture.getCompanyName());

      result += String.format("\t%20s",

                 manufacture.getCompanyAddress().getState());

      return result;

  }  

}

Explanation:

  • Create a manufacturer class to store and get information about company name and company address.
  • Create a product class to hold the manufacturer object, product name and other relevant information.
4 0
1 year ago
given:an int variable k,an int array currentMembers that has been declared and initialized,an int variable memberID that has bee
Oksi-84 [34.3K]

Answer:

// The code segment is written in C++ programming language

// The code segment goes as follows

for (k = 0; k < nMembers; k++)

{

//check if memberID can be found in currentMembers

if (currentMembers[k] == memberID){

// If yes,

// assigns true to isAMember

isAMember = true;

k = nMembers;

}

else{

isAMember = false;

// If no

// assigns false to isAMember

}

}

// End of segment:

The following assumption were made in the code segment above.

There exists

1. An already declared and initialised int array currentMembers.

2. An already initialised int variable memberID

Line 3 initiates a loop to scan through the array

Line 6 checks for the condition below

If current element of array equals memberID then

It assigns true to isAMember and nMembers to k

Else

It assigns false to isAMember

7 0
1 year ago
The symbol asterisk(*) in a select query retrieves​
Natali [406]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The symbol asterisk (*) in a select query retrieve all result of column in the table. For example, table named "employee" has three column such as <em>id, name, address</em>.

To apply the symbol asterisk (*) in select querry select all the columns in the result.

for example:

select * employee;

this query statement selects all columns of table "employee" in the result.

3 0
1 year ago
Other questions:
  • A two-dimensional array can have elements of ________ data type(s).
    7·1 answer
  • Explain how abstraction is used in a GPS system
    12·2 answers
  • In the game Beehive, you play the role of a worker bee who must watch over her hive. Your duties include (among others) directin
    12·2 answers
  • If the computer has an encrypted drive, a ____ acquisition is done if the password or passphrase is available. a. passive b. sta
    8·1 answer
  • You are attempting to open a file containing a list of integer numbers, each on a separate line, and read them into Python as in
    6·1 answer
  • I need to write a really simple python program to solve this issue. I have most of the program written but, when I run the secon
    8·1 answer
  • 12) Suppose you wanted a subroutine to return to an address that was 3 bytes higher in memory than the return address currently
    11·1 answer
  • Probability of theft in an area is 0.03 with expected loss of 20% or 30% of things with probabilities 0.55 and 0.45. Insurance p
    5·1 answer
  • Write an expression that continues to bid until the user enters 'n'.
    9·1 answer
  • What do you call the two parts of lift that go down a mine
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!