[SOLVED] CMSC401-Trial Assignment

20.99 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

Rate this product

Write a program that prints the multiplication of two selected numbers from a line

  • First line of input contains the number of lines to follow
  • First number of each line, n>=4 and n<=1000, contains the number of integers that follow in the line
  • Those n integers (each integer >=0; <=1000) follow till the end of the line, and should be stored (except the last two) in an array using index numbers 1…n-2
  • The last two integers x, y (x,y>=1 & x,y<=n-2) in the line is the index

(starting from 1) of the integers from the line to multiply and print Example: (colors are just for visualization):

Input:                                                              Output:

3

  • 13 2 5 1 3
  • 5 3 6 7 4 2

9 7 12 2 14 5 7 9 6 3

Input/output in Java

  • Use Standard I/O to read input and write the result For Java, input: System.in, output: System.out
  • To read numbers, one option is:
  • Use a single Scanner object Scanner sc = new Scanner(System.in);
  • Use nextInt()over and over to read integers

number = sc.nextInt(); • To print numbers: System.out.println(x);

  • “Do Not”s
  • Do not read from a disk file/write to disk file
  • Do not write anything to screen except the result
    • Ex: Human centric messages (“the result is”, “please enter..”)
    • Automated grading via script will be used for checking correctness of your outputde:
  • Java source code in a single file java (all lower case letters!)
  • The file should have your name in a comment in the first line
  • Remember: in Java, class name should match the file name, and is case sensitive
  • Please do NOT create your own packages
  • Do NOT place the file into a folder – just zip the file
  • Use standard I/O to read input (System.in, System.out) and output Make sure the program compiles
Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.