Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 . ( 3 0 pts ) Write a Java program A 1 p 1 . java with a public class A 1 p 1

1.(30 pts) Write a Java program A1p1.java with a public class A1p1 and no named packages. The program should take two command line arguments assumed to be integers a and b (with a less than b) and print the integers a,a+3,a+6,a+9,...,(up to b). Each line should contain five integers separated by commas with no comma after the last integer on each line (the last line is allowed to contain less than five integers). Further, if any integer is a multiple of 7, it should be printed between a pair of curly braces. Two sample runs look like the following (Note: in sample runs, blue color means those typed by the user while others are displayed by the program or the command window itself):
[kwang@computer][~/temp]$ java A1p1547
5,8,11,{14},17
20,23,26,29,32
{35},38,41,44,47
[kwang@computer][~/temp]$ java A1p1-359
-3,{0},3,6,9
12,15,18,{21},24
27,30,33,36,39
{42},45,48,51,54
57
2.(30 pts) Write a C program A1p2.c that works in the same way as A1p1.java. Two sample runs look like the following:
[kwang@computer][~/temp]$ A1p2547
5,8,11,{14},17
20,23,26,29,32
{35},38,41,44,47
[kwang@computer][~/temp]$ A1p2-361
-3,{0},3,6,9
12,15,18,{21},24
27,30,33,36,39
{42},45,48,51,54
57,60
3.(40 pts)(see TestScanfandCondition.c in Folio if needed) Write a C program A1p3.c to read from stdin a specified number of lines of input (each line can be assumed to contain a pair of integers separated by a space). The program should print the product of the two numbers after each line is received. A sample run looks like the following:
[kwang@computer][~/temp]$ ./A1p3
How many pairs to input? 3
12
The product of 1 and 2 is 2.
56
The product of 5 and 6 is 30.
9-28
The product of 9 and -28 is -252.

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

DNA Databases

Authors: Stefan Kiesbye

1st Edition

0737758910, 978-0737758917

More Books

Students also viewed these Databases questions

Question

What is a business risk?

Answered: 1 week ago