Question

Write a program which takes in two integers and produces their quotient. Here is a sample...

Write a program which takes in two integers and produces their quotient. Here is a sample of their output:
If you input 135 and 12, the output should read:
135 divided by 12 is 11 remainder 3.

using java, netbeans

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;

public class HomeworkLibquotient {

void quotient(int x,int y)

{

try{

int a,b;

a=x/y;

b=x%y;

//135 divided by 12 is 11 remainder 3.

System.out.println(x+" divided by "+y +" is "+a+" remainder "+b+".");

}

catch(Exception e)

{

System.out.println(e);

}

}

public static void main(String args[])

{

HomeworkLibquotient t=new HomeworkLibquotient();

Scanner sc=new Scanner(System.in);

int x,y;

System.out.println("enter first integer");

x=sc.nextInt();

System.out.println("enter second integer");

y=sc.nextInt();

t.quotient(x,y);

}

}

胚i-3 DDE TiDDE Ti

Add a comment
Know the answer?
Add Answer to:
Write a program which takes in two integers and produces their quotient. Here is a sample...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that takes in two integers and finds the remainder of the first integer...

    Write a program that takes in two integers and finds the remainder of the first integer divided by the second integer, WITHOUT USING THE MOD OPERATOR. You may not use the modulus operator to do this, you are to use a looping construct to do this. C++

  • In C++, Write a program that it prompts to user for two integers, computes the quotient...

    In C++, Write a program that it prompts to user for two integers, computes the quotient of two integers, and then displays the result. You need to do the following things in this assignment: + The main function prompts for user input and reads the two integers that the user entered. + Write a quotient function that computes the quotient of two integers and return the results. (hint: avoid integer division and divide by zero)

  • in java 3) Sum. Write a program that prompts the user to read two integers and...

    in java 3) Sum. Write a program that prompts the user to read two integers and displays their sum. Your program should prompt the user to read the number again if the input is incorrect.

  • FOR JAVA Write a program that takes two command line arguments: an input file and an...

    FOR JAVA Write a program that takes two command line arguments: an input file and an output file. The program should read the input file and replace the last letter of each word with a * character and write the result to the output file. The program should maintain the input file's line separators. The program should catch all possible checked exceptions and display an informative message. Notes: This program can be written in a single main method Remember that...

  • Write a program whose input is two integers and whose output is the two integers swapped....

    Write a program whose input is two integers and whose output is the two integers swapped. Write in C language 7.3 LAB: Swapping variables Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the input is: 38 then the output is: 83 Your program must define and call a function. SwapValues returns the two values in swapped order. void SwapValues(int* userVali, int* userVal2) ACRIVITY 7.3.1: LAB: Swapping variables 0/10 ] main.c...

  • . Write a program that takes integers from the user one at a time. Assume the...

    . Write a program that takes integers from the user one at a time. Assume the input is some number of positive integers. The user will type in 0 to end the input and the 0 should not be counted as input. Your program should find how many times the user enters a multiple of 5 and then print it to the screen. If the input is 6 10 30 5 0, the output is 3 because 10, 30, and...

  • Write an assembler program that asks the user (as shown below) for two integers and a...

    Write an assembler program that asks the user (as shown below) for two integers and a single character representing the arithmetic operations: addition, subtraction, multiplication and integer division (displays both quotient and remainder). Perform the requested operation on the operands and display the result as specified below. Assume SIGNED NUMBERS. The program should not divide by 0! If the user attempts to divide by 0, display the error message: "Cannot divide by zero." If this error occurs, the program should...

  • Hi. Intro Java hw help needed; Update an existing Java program that inputs two integers and...

    Hi. Intro Java hw help needed; Update an existing Java program that inputs two integers and outputs their sum, quotient and remainder by adding code to also output the difference and product.

  • by netBeans C++ java by netBeans C++ java by netBeans C++ java 1. Answer the following...

    by netBeans C++ java by netBeans C++ java by netBeans C++ java 1. Answer the following question a) (4 marks) Write a Java method, which takes an integer array and two integers x and y as input parameters. The method should exchange the value in position x with the value in the position y in the array. Example: If x = 1, y=2 Input Array Output Array b) (4 marks) Write the main method to do the following: 1. Define...

  • C++ Programming question Problem: 5. Write a program that reads in a list of integers into...

    C++ Programming question Problem: 5. Write a program that reads in a list of integers into an array with base type int. Provide the facility to either read this array from the keyboard or from a file, at the user's option. If the user chooses file input, the program should request a file name. You may assume that there are fewer than 50 entries in the array. Your program determines how many entries there are. The output is to be...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT