write a program that first asks the user to enter three real numbers using GUI input. Print the sum if all three numbers are positive, print the product of the two positive numbers if only one is negative - use a nested if. Then, ask the user to enter two real numbers from the console. If both numbers are negative, print the quotient.

Answers

Answer 1

Answer:

Here is the complete program:

import javax.swing.JOptionPane;  //to use GUI in JAVA application

import java.util.Scanner;  //to take input from user at console

public class Main {

public static void main(String[] args) {  //start of main function body

 String num1, num2,num3;  //declare three variables to store strings of numbers for input dialog

 double number1, number2, number3, sum,product; //declare three double type variables to hold the real numbers  

 num1 = JOptionPane.showInputDialog("num1");  //shows a dialog box prompting user to enter value of first number i.e. num1

 number1 = Double.parseDouble(num1);  //scans and reads the value of first input number i.e. number1    

 num2 = JOptionPane.showInputDialog("num2");  //shows a dialog box prompting user to enter value of second number i.e. num2

 number2 = Double.parseDouble(num2);   //reads number2  

               num3 = JOptionPane.showInputDialog("num3");  //shows a dialog box prompting user to enter value of third number i.e. num3

 number3 = Double.parseDouble(num3);   //reads number3  

   if(number1>0&& number2>0 && number3>0){  //checks if all three numbers are positive

   sum = number1 + number2+ number3;  //displays the sum by adding all three positive numbers

   JOptionPane.showMessageDialog(null, "the sum is : " + sum , "Results", JOptionPane.PLAIN_MESSAGE );      }   // displays the result of sum in a message dialog box

 

    if(number1<0 && number2>0 && number3>0)      {  //checks if number2 and number3 are positive

   product = number2*number3;  //computes product

   JOptionPane.showMessageDialog(null, "the product is : " + product , "Results", JOptionPane.PLAIN_MESSAGE );      }  //displays the result

   else if (number2<0&&number1>0&&number3>0){  //checks if number1 and number3 are positive

    product = number1*number3;  //computes product

JOptionPane.showMessageDialog(null, "the product is : " + product , "Results", JOptionPane.PLAIN_MESSAGE );      }  //displays the result

   else if (number3<0 && number1>0 && number2>0)     {  //checks if number1 and number2 are positive

     product = number1*number2;  //computes product of 2 positive numbers

     JOptionPane.showMessageDialog(null, "the product is : " + product , "Results", JOptionPane.PLAIN_MESSAGE );      }  //displays the result

   else     {  /.if all the numbers are positive.

/*However this part is optional. You can just use else part for above else if statement and exclude this else part. In this way the product of all three positive numbers is not computed and product is only computed when only two numbers of the three are positive */

     product = number1*number2*number3;  //computes product of all three positive numbers

     JOptionPane.showMessageDialog(null, "the product is : " + product , "Results", JOptionPane.PLAIN_MESSAGE );      }   //displays the result

Scanner scan = new Scanner(System.in);  //creates a Scanner class object

double value1 , value2, quotient;  //declares variables to hold the values of two real numbers and the result of division of the two real numbers is stored in quotient variable

System.out.println("Enter the first real number: ");  //prompts user to enter the value of first real number from the console

value1 = scan.nextDouble();  //reads the first number from user

System.out.println("Enter the second real number : ");  //prompts user to enter the value of second real number from the console

value2 = scan.nextDouble();  //reads the second number from user

if(value1<0&&value2<0)  {  //checks if both the numbers are negative

quotient = value1/value2;  //compute the quotient

JOptionPane.showMessageDialog(null, "the quotient is : " + quotient , "Results", JOptionPane.PLAIN_MESSAGE );    }  //displays result

 else  //if both numbers are not negative

JOptionPane.showMessageDialog(null, "Both numbers are not negative" );   //displays this message in a dialog box

  }  }

Explanation:

In the above given code if you want to display the outputs in console then alter the following statements as follows:

   if(number1>0&& number2>0 && number3>0){

   sum = number1 + number2+ number3;

  System.out.println("the sum is :  " + sum); }      

 

    if(number1<0 && number2>0 && number3>0)      {

    product = number2*number3;

      System.out.println("the product is :  " + product); }          

   else if (number2<0&&number1>0&&number3>0){

          product = number1*number3;

System.out.println("the product is :  " + product);      }

   else if (number3<0 && number1>0 && number2>0)     {

     product = number1*number2;

     System.out.println("the product is :  " + product);     }

   else     {

     product = number1*number2*number3;

      System.out.println("the product is :  " + product);      }

Scanner scan = new Scanner(System.in);

double value1 , value2, quotient;

System.out.println("Enter the first real number: ");

value1 = scan.nextDouble();

System.out.println("Enter the second real number : ");

value2 = scan.nextDouble();

if(value1<0&&value2<0)  {

quotient = value1/value2;

 System.out.println("the quotient is :  " + quotient);   }

 else  

System.out.println("Both numbers are not negative");

Notice that all the JOptionPane.showMessageDialog statement are changed with System.out.println which prints the results on the console.


Related Questions

A general rule for printing is to use _____ fonts for headlines and serif fonts for body text. sans-serif fantasy cursive monospace

Answers

Answer:

sans-serif

Explanation:

Fonts can be defined as a graphical representation of texts which includes a collection of characters such as numbers, letters, symbols etc in various size, color, typeface, design or weight.

A general rule for printing is to use sans-serif fonts for headlines and serif fonts for body text. This ultimately implies that, for any printed work such as novels, books, newspapers etc, it is a general rule for a printer to use sans-serif fonts for headlines and serif fonts for body text in order to enhance readability.

Also, it can be reversed in some instances by using a serif font for headlines and a sans-serif font for the body of a text.

Instructions
Currently, this program will add 6 and 3 together, output the math problem and output the answer. Edit this code so that a random number is generated from 1 - 10 (inclusive) for the variables a and b. Also, instead of adding the two numbers together, the edited program should multiply them, and output the proper math problem and answer. Be sure to update every line of code to reflect the changes needed. import random

Answers

Answer:

The original program is not given; So, I'll just write the program myself in python

import random

x = random.randint(1,10)

y = random.randint(1,10)

result = x * y

print(str(y)+" * "+str(x)+" = "+str(result))

Explanation:

The first line imports random

import random

The next two line generates random numbers between 1 and 10 and save in variables x and y

x = random.randint(1,10)

y = random.randint(1,10)

This line multiplies both numbers

result = x * y

This line prints the result

print(str(y)+" * "+str(x)+" = "+str(result))

The modified program written in python 3 is given below :

import random # import the random module for generating random numbers

a = random.randint(1, 11)#a random integer value between the values (1 and 10) is attached to variable a

b = random.randint(1,11)#a random integer value between the values (1 and 10) is attached to variable b

answer = a * b# multiplies the value of a and b and attach the result to the variable answer

print(str(a) + " * " + str(b) + " = " + str(answer))#displays the operation and result obtained as a string.

Learn more on python programs :https://brainly.com/question/16674303

Egyptian hieroglyphs were part of a writing system used by the ancient Egyptians. What type of graphic design elements did they contain?

Answers

Answer:

Logographic, syllabic, and alphabetic elements. I think thts what u were asking for?

Explanation:

How many bits are reserved for the Transmission Control Protocol (TCP) flags?

Answers

It’s 6 bits are reserved for the 6 TCP control flags. A connection, at which layer, implies that every segment of data sent is acknowledged? transport; A connection at the transport layer implies that every segment of data sent is acknowledged.

If you have a document that is relevant to more than one folder in your computer what should you do?

Answers

Answer:

save it to my docs

Explanation:

How can you say that a computer is a versatile machine?​

Answers

Answer:

A computer is a versatile machine because is used for many purposes,a modern day computer can run multiple data at once making a fast and efficient machine very durable and effective for our use in all areas of life.

What does the security element of non-repudiation mean in e-commerce cybersecurity? A. Data needs to be available at all times. B. Only authorized personnel can access data. C. Each website should have privacy control settings. D. Clients cannot refuse to make payments once they place an order.

Answers

Answer:

Non-repudiation is the assurance that someone cannot deny the validity of something. Non-repudiation is a legal concept that is widely used in information security and refers to a service, which provides proof of the origin of data and the integrity of the data

Explanation:

Answer:

Clients cannot refuse to make payments once they place an order.

Explanation:

PLATO Cyber-security

I got 5/5 on the quiz.

Many of the first photographers were actullay scientists and inventors

Answers

Answer:

True, if its a true or false. Otherwise I am of no help.

Explanation:

Answer:

True

Explanation:

ASAP

Which tool is useful before starting to code a website?

Rough draft
Storyboard
Text editor
WYSIWYG

Answers

Answer:

Story board

Explanation:

I took the quiz and i have proof that its right if you want it (from flvs coding class 1.03 is the quiz i took)

What problems might you encounter when using the Web for research?
a. Lack of current news
b. Undocumented sources
c. Lack of search tools
d. Time-consuming searches
e. Unreliable conten

Answers

Answer:

b. d. e.

Explanation:

The web is a vast and endless database of information and has become an invaluable resource for research. That being said it can also bring with it many problems, the main one being unreliable content due to undocumented sources, false testimonies, information with no evidence, etc. The amount of false information on the internet can sometimes make it very time consuming since you have to take the extra step of verifying the information you come across. Despite this, the WEB has information on every topic including current news, and with the wide array of search tools available it is very easy to find what you are looking for.

Which is used to input information on a laptop? Mouse Power button Memory storage Speakers

Answers

Answer:

Keyboard – one of the primary input devices used to input data and commands.

Explanation:

A laptop keyboard is more compact than a desktop keyboard to make the laptop smaller and lighter.

Answer:

mouse

Explanation:

flvs

What makes Java platform independent?

Answers

Answer:

Java it is the use of Byte code that makes it platform independent.

Explanation:

Java platform independent language allows its the end users to access they source code and other language automatically,its a human readable language.

Java is created in the James Gosling at the sun micro systems,and java is an open source programming language, generally the people refer the java because its source connections.Java code may be use sequence of machine that can be use executed by the directly CPU,and all the program in java are compiled by java c.Java is an independent platform and variety of methods, its object oriented language, and java is study platform.Java program are compiled into byte code and that byte code is platform independent, and they machine execute the byte code the java virtual machine.Java is the platform independent because it does not depend on the type of platform,and the virtual machine also interpret the representations.Java compiler is the .class file or the byte code and the machine native code,java is that depend on java virtual machine.Java is does not required any licence to the run and they also reliable platform to work on.

Help meeeee - Improved Pet App


Try out the improved version of the pet app that gives the user information about pet stores close by, which uses new sources of input. Determine the information that the app gets from each source of input.


User


Phone Sensors


Internet








Answers

Answer:

Did you do it? Can you give me the answers please‍♀️

Explanation:

Pleaseeeeeeeeeeeeeeeeeeeeeeeeeeeee

which of the following is involved in ordering an outline. A.grouping B.merging C.organizing D.arranging

Answers

Answer:

The answer is A.GROUPING

HOPE THIS HELPS...

Answer:

nice name

Explanation:

1. Which of the following is a result of a successful negotiation?
Mediation
Win-win outcome
Conflict resolution
Consensus

Answers

Maybe a Win win outcome
I guess its Win-win outcome.
Thank you!

Which of the following is not true about templates?

It incorporates formatting elements.

They slow down the process of creating presentations.

It incoprorates layout options.

It may include content that can be modified.

Answers

The answer is they slow down the creating of presentations.

the time a computer takes to start has increased dramatically, one possible explanation for this is that the computer is running out of memory. this explanation is a scientific....
a. hypothesis
b. experiment
c. observation
d. conclusion

Answers

Answer:

A

Explanation:

The appropriate answer will be Option c (observation).

Being able to comprehend or recognize something or be able to notice it his ability to observe in great depth is evident in every explanation or statement, which would be determined as an Observation.The result of observing or noting something, and then forming or expressing a judgment or a king of opinion.

The other given choices,

Experiment or hypothesis - Tests are used to examine a hypothesis or maybe even a concept through the utilization of such an experiment.

Conclusion - The final component of anything or a conclusion made following considerable deliberation.

Are not related to the given scenario. Thus the above option is the right one.

Learn more about observational learning here:

https://brainly.com/question/21861086

Which expansion slot is used by an NVMe compliant device?
1. PCI
2.USB-C
3.PCIe
4. SATA.

Answers

Answer:

3. PCIe

Explanation:

An expansion card is a slot on the motherboard of a computer which allow users use an additional feature such as network, video, sound that may not be available before.

PCIe is an expansion slot that is used by an NVMe compliant device. NVMe is the short form or acronym for “Non–Volatile Memory express. ”

Write a program that performs the following tasks: Display a friendly greeting to the user Prompt the user for the value to convert (a String) Accept that String Prompt the user for the value of the initial base (an integer) Accept that integer Prompt the user for the desired base of the output (an integer) Accept that integer If the String is not a legal expression of a number in the initial base, display an error message and exit the program. Convert the value represented by the String in the initial base to the desired base. Display the result.

Answers

Explanation:

import java.util.Scanner;

import java.math.BigInteger;

public class Main

{

private int x;  

public static boolean isValidInteger(String theValue, int theBase)

{    

BigInteger number = new BigInteger(theValue,theBase);

if(theValue.equals(number.toString(theBase)))

{

return true;

}

else

return false;

}

public static String convertInteger(String theValue, int initialBase, int finalBase)

{

boolean valid=isValidInteger(theValue,initialBase);

if(valid==true)

{

BigInteger number = new BigInteger(theValue);

return(number.toString(finalBase));

}

else

return("String not in initial base");  

}

public static void main(String[] args)

{

System.out.println("Welcome");

String value;

int ibase, dbase;

if(args.length==0)

{

Scanner S = new Scanner(System.in);

System.out.println("Enter Value to be converted :: ");

value = S.nextLine();

System.out.println("Enter initial base :: ");

ibase = S.nextInt();

System.out.println("Enter desired base :: ");

dbase = S.nextInt();

}

else

{

value=args[0];

ibase=Integer.parseInt(args[1]);

dbase=Integer.parseInt(args[2]);

}

  System.out.println("Change base "+convertInteger(value,ibase,dbase));  

}

}

Output

Students who respond promptly to e-mails are following which netiquette rule?

A. keeping content appropriate
B. assessing an online environment
C. respecting everyone’s time
D. practicing ethical behaviors

Answers

Answer:

respecting everyone's time

Explanation:

they don't make people wait for a response

Its Option C - Respecting Everyone’s Time.
Thank you!

briefly explain the usage of the MS PowerPoint

Answers

Answer:

PowerPoint is a computer program that allows you to create and show slides to support a presentation. You can combine text, graphics and multi-media content to create professional presentations.

Answer:

Making your presentation more interesting through the use of multimedia can help to improve the audience's focus. PowerPoint allows you to use images, audio and video to have a greater visual impact. These visual and audio cues may also help a presenter be more improvisational and interactive with the audience.

How to Print output in JavaScript

Answers

If you want to print on a page you can use

document.write();

If you want to write in console then there are multiple options

console.log() - to log information

console.error();- to log errors

console.warn(); - to log warning message

If you want to popup some information the you can use -

alert(message);

there are also various options present in alert.

or

print() essentially just calls up the native print dialog for a given window.

But as you're are thinking, it will work on any window or (i)frame.

thus if you write content to a frame, you can then call this to print it.

window.frameName.print();

note the only drawback (and its a big one), is that this calls up the print dialog... not the print preview window... thus the user doesn't really get a chance to see what they are printing and/or scale it to fit their printer/paper.

I personally wish that all browsers would implement the following to handle the above issue.

window.printPreview();

Hope this will help !!!

Answer:

Just add "document.wright();" to print text.

The binary string 00100100 is a member of which of the following problems? Remember, a "problem" is a language whose strings represent the cases of a problem that have the answer "yes." In this question, you should assume that all languages are sets of binary strings interpreted as base-2 integers. The exception is the problem of finding palindromes, which are strings that are identical when reversed, like 00100100, regardless of their numerical value.

Answers

This question is incomplete, the complete question is;

The binary string 00100100 is a member of which of the following problems? Remember, a "problem" is a language whose strings represent the cases of a problem that have the answer "yes." In this question, you should assume that all languages are sets of binary strings interpreted as base-2 integers. The exception is the problem of finding palindromes, which are strings that are identical when reversed, like 00100100, regardless of their numerical value.

a) Is the given string a palindromes ?

b) Is the given string a perfect cube?

c) Is the given string greater than 50?

d) Is the given string even?

e) is the given string a perfect square?

Answer:

a) the given binary string is a palindromes

b) the given string is NOT a perfect cube

c) the given string is NOT greater than 50?

d) the given string is an even

e) the given string a perfect square

Explanation:

Given that;

binary string : 00100100

a)

Is the given string a palindromes ?

the given binary string = 00100100

now when you reverse the string, its still going to be : 00100100

so the given binary string is a palindromes

b)

Is the given string a perfect cube

the given string : 00100100 = 36

now 2^3 = 8,

3^3 = 27,

4^3 = 64

so 36 is not a perfect cubic

hence the given string is NOT a perfect cube

c)

Is the given string greater than 50?

the given string : 00100100 = 36

and 36 < 50

so the given string is NOT greater than 50?

d)

Is the given string even?

the given string  : 00100100 = 36

and 36 can be divided exactly by 2

so the given string is an even

e)

is the given string a perfect square?

the given string  : 00100100 = 36

now 6^2 = 36  i.e 6 multiply by 6 = 36

therefore the given string a perfect square

When performing actions between your computer and one that is infected with a virus, which of the following offers No risk of your computer becoming infected?
A. Printing to the same printer as infected computer
B. Accepting email attachments sent from an infected computer
C. Sharing Word documents with an infected computer
D. Sharing removable disks with an infected computer

Answers

Answer:

d

Explanation:

The correct option is D: Sharing removable disks with an infected computer

Removable disks are disks that use to keep data as well transfer data or information from one computer to another computer.

With Removable disks a computer infected with a virus cannot infect another Computer as the what the user does is to simply insert  the USB port of the  Removable disks into the computer which inturn enable the transfer of data to the computer to take place .

Learn more about Removable disks here:

https://brainly.com/question/4327670

To the greatest extent possible, coalition members should _____.

Answers

Answer: consider the ramifications of labeling information about operational areas as intelligence

Explanation:

The options to the question are:

a. consider the ramifications of labeling information about operational areas as intelligence

b. prevent the sharing of relevant intelligence about the situation and adversary

c. occasionally seek the necessary authorization for foreign disclosure of information

d. disseminate information freely without a tear line.

To the greatest extent possible, coalition members should, consider the ramifications of labeling information about operational areas as intelligence.

It should be noted that security operations activities are conducted by U.S. forces in order to demonstrate the commitment of the U.S to its alliances, and also enhance regional stability.

A network is:
A. A group of people or things that are individually connected to one another.
B. A number of individuals who share the same values and ideas.
C.a means of mass communication in print and other forms.
D. The main idea or information contained in a media piece.

Answers

Explanation:

The answer to this question is A

why is makyra a loser??​

Answers

Because she doesn’t have any friends :-(

Answer:

She dumbbbbbbbbbbbbbbbbbbbbbb

Explanation: Her mom watched too much spongebob while pregnant

$8.25/hour; _____$/year, when working 40 hours a week.

Answers

if you work 50 weeks/year and 40 hours/week, you will make 16,500 dollars per year if you make 8.25 per hour

When computers are connected and operate through one main computer, it is called a _________ network. centralized client server GUI peer-peer

Answers

Answer:

the answer would be a client server

Explanation:

In a situation wherein computers are connected and operate through one main computer, it is called a client server network. Therefore, the option B holds true.

What is the significance of a client server network?

A client-server network can be referred to or considered as a network wherein all the systems that are collectively a part of the computer network are controlled and handled by a single system. This single system of computers is also known as the main computer.

The main computer has access to all the data, as well as information tracking of the activities performed by the main computer. In order to access anything between the different systems, the members systems need to get authorized access through the main computer.

Therefore, the option B holds true and states regarding the significance of a client server network.

Learn more about a client server network here:

https://brainly.com/question/28099574

#SPJ2

Analyze the problem statement. Select the correct answer. Vision: We want to decrease errors in our billings to clients. Issue: It may be that we have too many new clients. Method: Develop new software that has multiple checkpoints of billing amounts before invoices are issued. This is a clear, well-defined problem statement. This problem statement will help the staff to focus. This problem statement does not provide a useful issue statement. This problem statement is specific.

Answers

Answer:

answer is B :)

Explanation:

Vision: We want to decrease errors in our billings to clients. This is a clear, well-defined problem statement was the solution.

What is clients?

The individual or customer who utilizes the services of a company, client, or organization is referred to as a “client.” The customer both uses the company's services and pays for them. The customer mostly purchases the company's services in accordance with her preferences and choices.

According to the vision of the given statement. Vision: We want to decrease errors in our billings to clients. It was the issued that so many clients. It was the clear, well-defined issue statement. It was the clear on the statement as easy to analyze that.

As a result, the conclusion of the is a clear, well-defined issue statement was the solution are the aforementioned.

Learn more about on client, here:

https://brainly.com/question/29051195

#SPJ3

Other Questions
When 14.8 g KOH is dissolved in 85.6 g of water in a coffee-cup calorimeter, the temperature rises from 19.3 C to 32.76 C. What is the enthalpy change per gram of potassium hydroxide dissolved in the water? how would high tariffs help america The period known as the gilded age was marked by Simplify (4.5)(5)(2). 45 4.5 4.5 45 difference between compound and element Exercise is most beneficial when you exercise at the correct intensity. How can you determine if you are exercising at the right intensity? Lipids are considered *HydrophobicPolarHydrophilicLike little magnets Taggart Goods Corp. just reported a net income of $8,000,000, and its current stock price is $17.50 per share. Taggart is forecasting an increase of 25% for its net income next year, but it also expects it will have to issue 2,400,000 new shares of stock (raising its shares outstanding from 5,500,000 shares to 7,900,000 shares). If Taggarts forecast turns out to be correct and its price-to-earnings (P/E) ratio does not change, what does management expect its stock price to be one year from now? (Hint: If you choose to compute the firms price/earnings ratio, round its value to four decimal places.) I have a math test coming up and this geometry stuff is just always confusing me. With that said if you could explain your answer that would be wonderful.If the image is to blurry please just click on the image it is much easier to read.I am willing to mark a person branliest!All help is very appreciated. Good Luck. God Bless. Stay Safe. Thanks Max Larson Write a function g whose graph represents the indicated transformation of the graph of f.f(x) = 4 - 6x +11 Which is the result of a seasonal change? A. A bear hibernating. B. A bat capturing mosquitoes. C. Average temperatures rising each year. D. Trees dying from air pollution. y - 1 > -7 A.y -6 B.y > -6 C.y -8 MaTh whoever answers this get BrAINLY Jerome has $28 in his pocket. He wants to buy as many candy bars as he can for $1.75 cach. Write an equation to show how many candy bars he can buy? Scientists have changed the model of the atom as theyhave gathered new evidence. One of the atomicmodels is shown below.What experimental evidence led to the development ofthis atomic model from the one before it?A few of the positive particles aimed at a gold foilseemed to bounce back.The colors of light emitted from heated atoms hadvery specific energies.Experiments with water vapor showed that elementscombine in specific proportions.Cathode rays were bent in the same way whenevera magnet was brought near them. The major organic macromolecules are include all of the following EXCEPT- > a. carbohydrates b. water c. proteins d. lipids e. nucleic acids why was dissection a major advance in health care during the renaissance? Which of the following did Europeans introduce tothe Americas? During Reconstruction, Southern states often added to their economic problems by? Malcolm wrote 294 more lines of code than Sheila. Sheila wrote 1,275 lines of code. How many lines of code did Malcolm write?