Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program named randomsum.java that asks the user to enter a number. The program then calculates 4 random numbers that sum up to the

Write a program named randomsum.java that asks the user to enter a number. The program then calculates 4 random numbers that sum up to the user's numbers. It should output different (random) numbers each time. Below are some example runs:

Please enter an Integer: 100

These numbers sum up to 100: 50, 8, 19, 23

Please enter an Integer: 100

These numbers sum up to 100: 17, 42, 5, 36

Please enter an Integer: 25

These numbers sum up to 25: 1, 9, 11, 4

I have started it but I need help

image text in transcribed

1 package randomsum; 3e import java.util.Scanner; 4 import java.util.*; 6 public class RandomSum public static void main(String[] args) 9e 10 Scanner in = new Scanner (System.in); System.out.println("Enter a number:"); int Numin.nextInt(); 12 13 14 15 16 17 18 19 20 21 int A, B, C, D; A (int) (Math. random) Num) 1; B = (int) (Math.random() * (Num-A)) + 1; C-(int) (Math. random) (Num-A-B)) + 1; D(int) (Math.random() * (Num-A-B-C)) 1; System.out, printin ("Your numbers +D); " "" +B+ "" +C+ "" are +A+ 23 24 25e 26 int A0, B0 327 while (A + BNum) 28 x29 A(int) (Math.random() *Num) +1; B(int) (Math. random() *Num) + 1; 330 31 H 32 System.out.println ("Your numbers are " +A+ "" +B); 34 35 36h 37 Console kterminated> RandomSum [Java Application] /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/bin/java (Feb 6, 2019, 3 Exception in thread "main" java. lang.Error: Unresolved compilation problem: at randomsum/randomsum. RandomSum.main(RandomSum.java:9)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic Net Database Programming

Authors: Rod Stephens

1st Edition

0789726815, 978-0789726810

Students also viewed these Databases questions