Refactor NavigateSearch ProjectWindow HelpEclipseFileEdit SourceFri Oct 4 10:53:23 PMRun35%eclipse-workspace - Project1-FirstDay/TryAgain.java - Eclipse IDEQuick Acces010Ра XLab.javaTianna.javaChapter3ProjectTake1.java*TryAgain.java4 import java.util.Random;5 import java.util.Scanner;6 public class TryAgainChapter_3Chapter2JRE System Iprivate static final int remainder80;=9EI resourcespublic static void main(String[] args){10e1119 rt.jar - /Liljsse.jar -12jce.jar /LI9charsets.j13= new Scanner(System.in);= new Random();Scanner inputRandom rnd141516jfr.jar - /Lisunec.jarO10rnd.nextInt 101)int x ={System.out.print("Please enter a number between 1 and 4: ");}int y17nashorn.ja18010 cldrdata.ja19jfxrt.jar20Eוinput.nextInt ( ) ;.21dnsns.jarO1022010 localedataint remainder23у % х;sunjce_pr24sunpkcs1if (remainder{System.out.print("The number0)O10o2526jaccess.jaO10y " is a factor ofх);27+zipfs.jarO1028MRJToolkelse29Chpt3_Quiz_Tiai{System.out.print("The number}30JRE System lх)%;y " is not a factor of31(default pack3233J Lab.java34idkProject1-First DConsoleXJRE System terminated> TryAgain [Java Application] /Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/bin/java (Oct 4, 2019, 10:42:21 PM)(default pack Please enter a number between 1 and 4: 2Tianna.jav The number 2 is not a factor of 90TryAgain.jWritableSmart Insert21 41WP52723.141593ОСТWP9CDLO

Question
Asked Oct 5, 2019

I am trying to write a java code to see if the number entered by the user is a factor of the random number generated from the import java.util.Random. When I run it it keeps saying the number entered by the user is not a factor of the random number. 

 

Another thing is the output is suppose to look like this... The value <number entered by user> is a / not a factor of <random number>

how would I fix what i have to look like that?

Refactor Navigate
Search Project
Window Help
Eclipse
File
Edit Source
Fri Oct 4 10:53:23 PM
Run
35%
eclipse-workspace - Project1-FirstDay/TryAgain.java - Eclipse IDE
Quick Acces
010
Ра X
Lab.java
Tianna.java
Chapter3ProjectTake1.java
*TryAgain.java
4 import java.util.Random;
5 import java.util.Scanner;
6 public class TryAgain
Chapter_3
Chapter2
JRE System I
private static final int remainder
8
0;
=
9
EI resources
public static void main(String[] args)
{
10e
11
19 rt.jar - /Lil
jsse.jar -
12
jce.jar /L
I9charsets.j
13
= new Scanner(System.in);
= new Random();
Scanner input
Random rnd
14
15
16
jfr.jar - /Li
sunec.jar
O10
rnd.nextInt 101)
int x =
{
System.out.print("Please enter a number between 1 and 4: ");
}
int y
17
nashorn.ja
18
010 cldrdata.ja
19
jfxrt.jar
20
Eו
input.nextInt ( ) ;.
21
dnsns.jar
O10
22
010 localedata
int remainder
23
у % х;
sunjce_pr
24
sunpkcs1
if (remainder
{
System.out.print("The number
0)
O10
o25
26
jaccess.ja
O10
y " is a factor of
х);
27
+
zipfs.jar
O10
28
MRJToolk
else
29
Chpt3_Quiz_Tiai
{
System.out.print("The number
}
30
JRE System l
х)%;
y " is not a factor of
31
(default pack
32
33
J Lab.java
34
idk
Project1-First D
ConsoleX
JRE System terminated> TryAgain [Java Application] /Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/bin/java (Oct 4, 2019, 10:42:21 PM)
(default pack Please enter a number between 1 and 4: 2
Tianna.jav The number 2 is not a factor of 90
TryAgain.j
Writable
Smart Insert
21 41
WP
5
27
2
3.141593
ОСТ
W
P
9
CD
LO
help_outline

Image Transcriptionclose

Refactor Navigate Search Project Window Help Eclipse File Edit Source Fri Oct 4 10:53:23 PM Run 35% eclipse-workspace - Project1-FirstDay/TryAgain.java - Eclipse IDE Quick Acces 010 Ра X Lab.java Tianna.java Chapter3ProjectTake1.java *TryAgain.java 4 import java.util.Random; 5 import java.util.Scanner; 6 public class TryAgain Chapter_3 Chapter2 JRE System I private static final int remainder 8 0; = 9 EI resources public static void main(String[] args) { 10e 11 19 rt.jar - /Lil jsse.jar - 12 jce.jar /L I9charsets.j 13 = new Scanner(System.in); = new Random(); Scanner input Random rnd 14 15 16 jfr.jar - /Li sunec.jar O10 rnd.nextInt 101) int x = { System.out.print("Please enter a number between 1 and 4: "); } int y 17 nashorn.ja 18 010 cldrdata.ja 19 jfxrt.jar 20 Eו input.nextInt ( ) ;. 21 dnsns.jar O10 22 010 localedata int remainder 23 у % х; sunjce_pr 24 sunpkcs1 if (remainder { System.out.print("The number 0) O10 o25 26 jaccess.ja O10 y " is a factor of х); 27 + zipfs.jar O10 28 MRJToolk else 29 Chpt3_Quiz_Tiai { System.out.print("The number } 30 JRE System l х)%; y " is not a factor of 31 (default pack 32 33 J Lab.java 34 idk Project1-First D ConsoleX JRE System terminated> TryAgain [Java Application] /Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/bin/java (Oct 4, 2019, 10:42:21 PM) (default pack Please enter a number between 1 and 4: 2 Tianna.jav The number 2 is not a factor of 90 TryAgain.j Writable Smart Insert 21 41 WP 5 27 2 3.141593 ОСТ W P 9 CD LO

fullscreen
check_circle

Expert Answer

star
star
star
star
star
1 Rating
Step 1

The following source code will print whether a number is a factor of generated random number or not in the format as specified in the question.

Step 2

Source Code

import java.util.Random;

import java.util.Scanner;

public class Check_Factor {

                        private static final int remainder=0;

            public static void main(String[] args) {

                        // TODO Auto-generated method stub

                        Scanner input=new Scanner(System.in);

                        Random rnd=new Random();

                        int x=rnd.nextInt(101);

                        System.out.print("Please enter a number between 1 and 4: ");

                        int y=input.nextInt();

                        int remainder=x%y;

      ...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Java

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: What are the implications of crypto currency to the international banking system?

A: A cryptocurrency is a kind of digital asset which is designed  to work as medium of exchange that us...

question_answer

Q: I need help answering the following quetions I am not good with code. 1. Describe how you use TCP Du...

A: Use the keyword tcpdump with the TCP Dump flag –D.The flag –D will list all the interfaces that are ...

question_answer

Q: I have to combine output variables in C++. My line of code: #include &lt;iostream&gt;using namespace...

A: Program://include the header file#include &lt;iostream&gt;using namespace std;//definition of main m...

question_answer

Q: Hello good afternoon, This is my first time using Bartleby, I am super slow in computer science and ...

A: Program instructions:Declare necessary variables.Open the file with the score and total points and r...

question_answer

Q: Who is Alan Turnig ?

A: Alan Turing was born in the year 1912 and died in the year 1954. He was a mathematician, computer sc...

question_answer

Q: What are the Windows 2016 "flavors"?

A: Windows Server 2016 comes in 3 flavors, which are, Server Core (no GUI), Server with Desktop Experie...

question_answer

Q: Show that xz = (x + y)(x + ~y)(~x + z) Using Truth Tables Using Boolean identities

A: 1.Answer: xz = (x + y) (x + ~y) (~x + z)LHS = xzRHS = (x + y) (x + ~y) (~x + z)1. Truth Table: 

question_answer

Q: Develop the ‘Shape’ application such that: Implement an array of objects of various types (all SIX ...

A: Program plan:Define a class called “ShapeTest”.Define a “main()” method.Create an array of six shape...

question_answer

Q: In C++ Create a function called Factorial. It should use a for loop to find the factorial of any inp...

A: Program code in C++ to create a function called factorial,  it uses a for loop to find the factorial...