1answer.
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
Nataly [62]
3 years ago
14

Write a Java program that reads two numbers from the console. Based on the example in the textbook, write five methods (min, max

, sum, difference, and product) to calculate and return the appropriate results. For the difference method, use the absolute value method and the round method from the Math class to refine your results to the nearest whole positive integer.
Computers and Technology
2 answers:
Digiron [165]3 years ago
5 0

Answer:

Sample run :

Enter two numbers:

11.75 1.5

The minimum of 11.75 and 1.5 is 1.5

The maximum of 11.75 and 1.5 is 11.75

The sum of 11.75 and 1.5 is 13.25

The difference of 11.75 and 1.5, , rounded to the nearest whole integer, is 10

The product of 11.75 and 1.5 is 17.625

Explanation:

import java.util.Scanner;

public class Reader {

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

System.out.println("Enter two numbers: ");

double num1 = scan.nextDouble();

double num2 = scan.nextDouble();

System.out.println("The minimum of " + num1 + " and " + num2 + " is "

+ min(num1, num2));

System.out.println("The maximum of " + num1 + " and " + num2 + " is "

+ max(num1, num2));

System.out.println("The sum of " + num1 + " and " + num2 + " is "

+ sum(num1, num2));

System.out.println("The difference of " + num1 + " and " + num2

+ ", , rounded to the nearest whole integer, is "

+ difference(num1, num2));

System.out.println("The product of " + num1 + " and " + num2 + " is "

+ product(num1, num2));

scan.close();

}

private static double product(double n1, double n2) {

return n1 * n2;

}

private static double sum(double n1, double n2) {

return n1 + n2;

}

// using the absolute value method and the round method from the Math class

// to refine the results to the nearest whole positive integer.

private static int difference(double n1, double n2) {

double diff;

diff = n1 - n2;

diff = Math.abs(diff);

int intDiff = (int) Math.round(diff);

return intDiff;

}

private static double max(double n1, double n2) {

if (n1 > n2) {

return n1;

} else {

return n2;

}

}

static double min(double n1, double n2) {

if (n1 < n2) {

return n1;

} else {

return n2;

}

}

}

makvit [3.9K]3 years ago
4 0

Answer:

import java.util.Scanner;

public class num6 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter first number");

       int a = in.nextInt();

       System.out.println("Enter second number");

       int b = in.nextInt();

       //Calling the methods inside the output statement

       System.out.println("Min is "+min(a,b));

       System.out.println("Max is "+ max(a,b));

       System.out.println("Sum is "+sum(a,b));

       System.out.println("Product is "+product(a,b));

       System.out.println("Absolute difference is "+difference(a,b));

   }

   //Min Method

   static int min(int a, int b){

       if (a<b){

           return a;

       }

       else {

           return b;

       }

   }

   //Max Method

   static int max(int a, int b){

       if (a>b){

           return a;

       }

       else {

           return b;

       }

   }

   //Sum Method

   static int sum(int a, int b){

       return a+b;

   }

   //Diference Method

   static int difference(int a, int b){

       int diff = Math.abs(a-b);

       return diff;

   }

   //Product Method

   static int product(int a, int b){

       int prod = a*b;

       return prod;

   }

}

Explanation:

  • Using Java programming language
  • Use the scanner class to prompt and receive two values from the user (integers a and b)
  • Create the four methods as required (Please see the comments in the code)
  • In the difference method use Math.abs() to get the absolute value of the subtraction ensuring that you get a positive number returned
You might be interested in
Where does the computer store instructions and data that are needed frequently by the cpu?
Elden [556K]
L1 Cache

There other cache levels but the most frequently used data is put in L1d (d for data) and L1i (i for instructions).


3 0
4 years ago
Create a website on budget
kaheart [24]

Answer:I bet your attention automatically tuned into the video background, right?  It’s almost impossible to ignore it as it is moving.

There’s nothing wrong with you – it’s just human nature and how we subconsciously decide where to pay our attention to.

We are easily distracted by anything that moves – just like that dog that ignores everything in its world to chase that pesky little squirrel!

“Okay, you got me to look at your silly video, what does this have to do with my website design?”

What a great question and I’m glad you asked.

A video background on your website, if used properly, can help you capture your website visitors’ attention too!

Video background is one of the most popular website design trend that seems to be here to stay.

Marketers love video backgrounds because they make websites look modern and create a sense of artistry that static background images simply can’t match up to.

Many website conversion experts and regular people alike see their visitors stay on their websites longer and more likely to sign up or opt-in to their product / service offers.

I’ll admit – a 138% improvement sounds extraordinary and challenging to achieve every other day.

Keep in mind that such high figure is from tests ran by conversion / business optimization professionals who do this for a living. So it’s fair to say not everybody who runs a DIY website will see similar improvements, just by adding a video background to their website.

However, even a 10% – 20% improvement in engagement and conversion is not unreasonable for even a first-time website owners with no professional help  – if you use video background on your homepage the right way!

Imagine if you collected email newsletter subscribers so you can follow up with special promotions or share interesting discussions to build your brand.

Consider what a 20% increase in subscribers can do to your business? This can mean more sales and/or higher brand awareness!

All this can be done if you can capture your visitors’ attention more effectively – by using a video background.

This is not just a hypothetical idea. A lot of real life case studies have demonstrated how many businesses have succeeded by using video backgrounds to improve sales.

Like all things in life, there is a right way and a wrong way of doing things.

Even with something as groundbreaking as a video background, you can still screw it up and end up hurting your overall website design and experience – if you don’t abide by some basic rules.

So, understanding how to avoid basic mistakes when using a video background on your homepage can give you a much higher chance of succeeding in improving your web design.

In this guide, we will show you all the steps and best practices you should take to use video background effectively:Video background is most effective when you use it to (1) create a vibe, (2) to set a tone or (3) to induce an emotional reaction.

Let’s check out some examples:

Example #1: Businesses, Services, Organizations

Video backgrounds work for most professional websites, whether you are running a clinic, consultancy business, or design agency.

You can use a video background to show clips of the life of your staff or even the process of helping a customer. This gives your potential clients a chance to get to know you before even talking to you. It also paints a very vivid visual representation of what they can expect to experience from your business.Grain & Mortar is a design agency. This example is interesting because it shows you that you don’t always need to have a full page video background to get a similar benefit. They only display a video in the header section of the page that takes no more than half the screen real estate.

The video shows the daily collaboration of the staff (strategy sessions) and how they create design solutions for their clients.

At this moment, video background themes are somewhat limited in Shopify’s Theme Store. You do get more selection if you search for Shopify Video Background Themes in third party providers like Themeforest.

Do keep in mind all themes available in Shopify’s Theme Store are screened, approved and supported by Shopify.

In comparison, Shopify Themes from third party providers do not undergo Shopify’s direct screening process. While I am not saying third party themes are not as good, I just want you to be informed if you are considering whether to purchase from a third party provider.

Explanation:

lol i know this is alot just copy and paste it and can i have a brain list

3 0
4 years ago
Computer programs typically perform three steps: input is received, some process is performed on the input, and output is produc
-Dominant- [34]
True. Most basic programs follow this structure.
6 0
1 year ago
Marketing có phải là bán hàng hay không? Giải thích?
barxatty [35]

Answer:

Sự khác biệt giữa bán hàng và tiếp thị là bán hàng tập trung vào làm việc trực tiếp với khách hàng tiềm năng để khiến họ chuyển đổi, trong khi tiếp thị tập trung vào việc khơi dậy sự quan tâm đến sản phẩm của bạn.

7 0
3 years ago
Read 2 more answers
7. Type the correct answer in the box. Spell all words correctly.
____ [38]

Catherine's team is using the concept of on-off device by using a single transmitter to reach multiple receivers.

<h3>What is a device?</h3>

It should be noted that a device simply means something that is adapted for a particular purpose especially an electronic equipment.

In this case, Catherine's team is using the concept of on-off device by using a single transmitter to reach multiple receivers.

Learn more about device on:

brainly.com/question/24786034

7 0
2 years ago
Other questions:
  • In Microsoft Excel graphs are referred to as ______?
    14·2 answers
  • Technician A says copper has a low resistance. Technician B says the length of wire doesn't affect resistance. Who is correct?
    11·1 answer
  • Develop an sec (single error correction) code for a 16-bit data word. generate the code for the data word 0101000000111001. show
    6·2 answers
  • To display rows from one table that do not have a corresponding row in the other table, you must create a(n) ___________________
    10·1 answer
  • Ok so sometimes when i do something i see a box with a question mark in it, how do i remove it, i am on a macOs High Sierra earl
    11·1 answer
  • EASY POINTS
    5·1 answer
  • How can a signature be added to an email message? Check all that apply.
    10·2 answers
  • What are the 3 symbols that can’t be used when saving a document? (From Microsoft Word 2016) (pls helped me!)
    6·1 answer
  • What is the difference between being an affiliate and an independent station ?what are the benefits to being an affiliate
    9·1 answer
  • What are the ways to search out a number from a tree?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!