Write a Java program

0 comments

1. write a Java program that first asks the user to enter two integers using JOptionPane. Print the sum, difference, product, quotient and modulus to the console and to a dialog – console output and gui output are both required. Then ask the user to enter two real numbers from the console and then print the sum, difference, product, quotient, and modulus of the two real numbers to the console and to a window – again console and gui output are both required. Supply meaningful prompts and format the output for the console – use printf and for real numbers specify the width and number of digits after the decimal. You must indent you code and follow java conventions.

2. 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.

All output should be to a dialog and the console – console output must be done using printf and format specifiers. Use meaningful variable names, informative prompts and label your output. Write a method getFloat to ask for the real numbers. This should be similar to the method getInt above. Good program structure, indentation, a heading and comments are required. Points will be deducted for any program not meeting the requirements. You must indent you code and follow java conventions.

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}