logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

Write  a C++ program to print all the coprime numbers below a certain given number.   Coprime numbers are numbers that do not share any common factors besides

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

1 Objective

The objective for this assignment is to make sure

You are familiar with repetitive structures (loops) and selection statements (if/else or switch) in any com- bination.

  • You can recover from wrong user

  • You are comfortable with console input and output involving numeric

  • You can approach a complex problem, break it down into various parts, and put together a

From this assignment, please make sure you conform to Output requirements. So far, we have allowed you to write your own output statements, print out intermediate steps, etc. You should now be familiar enough with cout statements and output formatting that you should be able to EXACTLY match the sample output (other than whitespace and floating point precision when it is not specified).

Turn in your 2 files coprimes.cpp and letters.cpp to Canvas.

2 Program 1 - CoPrime Numbers

SOP the great overlord of all things overlordy has a penchant for making whimsical decisions and seeks your  help in enforcing those decisions. Sop has,  in his infinite wisdom, decided that all under his purview will only  count in coprime numbers. He will randomly yell out a number and you need to show him all the numbers that  come before it, which are coprime to Sop’s number.

Write  a C++ program to print all the coprime numbers below a certain given number.   Coprime numbers are numbers that do not share any common factors besides 1. Make sure your program conforms to the following requirements:

  1. This program should be called cpp

  2. Accept the upper limit from the user (as an integer). (5 points)

  3. Make sure the number is at least 2. If it is not, terminate the program. (5 points).

  4. Go from 1 to the number. If you happen to find a number that is coprime, print it. (35 points)

  5. Add comments wherever necessary. (5 points)

2.1     Sample Runs

There are 3 sample runs here. (It’s OK if you have an extra comma at the end)

Enter the number: 8

The coprime numbers are:

3, 5, 7

Enter the number: 25

The coprime numbers are:

2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 21, 22, 23, 24

 

Enter the number: -7

Number is too small. Goodbye.

 

3  Program 2 - Printing Letters

Sop is very impressed with your work. He has another task for you, upon completion of which he will reward you with more money than you can imagine (and you can imagine a lot) . He has decided that he likes labeling things that belong to him. However, he believes his time would be better spent in acquiring things to label, and decides to delegate the menial task of inscribing his name, to you. In the same vein, you decide to write a program to perform this repetitive task. Write a C++ program to print the letters S, O and P in ASCII art. Make sure your program conforms to the following requirements:

  1. This program should be called cpp

  2. Accept the size of the letter (in the number of lines) from the user. This number should be an odd number greater than or equal to 5. If the value entered is invalid, tell the user so, and ask for another one. Repeat until you get a valid (6 points)

  3. Accept the letter to be printed from the user. If the letter is S, O or P, go to the next step. If not, tell the user that the letter is invalid, and ask for another Repeat until you get a valid letter. (6 points)

  4. Print the letter in ASCII art form. The sample run gives examples for each letter. ( 30 points, 10 per letter)

  5. Repeat the entire process if the user indicates they wish to continue. (4 points)

  6. Make sure you add comments to explain the logic. (4 points)

3.1 Sample Run

Welcome to the letter printer. Enter the size : 3

Invalid size. Enter the size again: -4 Invalid size. Enter the size again: 7 Enter the letter: C

Invalid letter: Enter the letter again: # Invalid letter: Enter the letter again: O

*******

*            *

*            *

*            *

*            *

*            *

*******

 

Would you like to continue? (Y or N): Y Enter the size: 8

Invalid size. Enter the size again: 11 Enter the letter: P

***********

*                     *

*                     *

*                     *

*                     *

***********

*

*

*

*

*

Would you like to continue? (Y or N): Y Enter the size: 9

Enter the letter: S

*********

*

*

*

*********

*

*

*

*********

Would you like to continue? (Y or N): N

General Requirements

  1. Include the header comment with your name and other information on the top of your files

  2. Please make sure you’re only using the concepts already discussed in class. Please restrict yourself to input/output statements, variables and operators, selection statements and loops. Using functions, arrays or anything more advanced will result in a loss of points

  3. Each program is worth 50 points

  4. If we have listed a specification and allocated point for it, you will lose points if that particular item is  missing from your code, even if it is trivial

  5. No global variables (variables outside of main() )

  6. All input and output must be done with streams, using the library iostream

  7. You may only use the iostream library (you do not need any others for these tasks)

  8. Please make sure that youre conforming to specifications (program name, print statements, expectedinputs and outputs etc.). Not doing so will result in a loss of points

  9. NO C style printing is permitted. (Aka, don’t use printf). Use cout if you need to print to the screen

  10. When you write source code, it should be readable and well-documented (comments).

  11. Make sure you either develop with or test with CLion (to be sure it reports no compile errors or warnings) before you submit the program

  12. Testing your program thoroughly is a part of writing good We give you sample runs to make sure you match our output requirements and to get a general idea of how we would test your code. Matching your outputs for JUST the sample runs is not a guarantee of a 100. We have several extensive test cases.

  13. Please make sure you’ve compiled and run your program before you turn it in. Compilation errors can be quite We  take 5 points off per compiler error for the first 9 errors.  The 10th compiler error will   result in a grade of 0.

  14. Only a file turned in through Canvas counts as a submission. A file on you computer, even if it hasn’t been edited after the deadline, does not count

  15. The student is responsible for making sure they have turned in the right file(s). We will not accept any excuses about inadvertently modifying or deleting files, or turning in the wrong files

  16. Program submissions should be done through the Canvas class page, under the assignments tab (if it’s not there yet I’ll create it soon.)  Do not send program submissions through e-mail –  e-mail attachments  will not be accepted as valid submissions

  17. The ONLY files you will submit via Canvas are cpp and damage.cpp

  18. General Advice - always keep an untouched copy of your finished homework files in your These files will have a time-stamp which will show when they were last worked on and will serve as a backup in case you ever have legitimate problems with submitting files through blackboard. Do this for ALL programs.

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

668 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

710 Answers

Hire Me
expert
Husnain SaeedComputer science

807 Answers

Hire Me
expert
Atharva PatilComputer science

973 Answers

Hire Me
June
January
February
March
April
May
June
July
August
September
October
November
December
2025
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
SunMonTueWedThuFriSat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
00:00
00:30
01:00
01:30
02:00
02:30
03:00
03:30
04:00
04:30
05:00
05:30
06:00
06:30
07:00
07:30
08:00
08:30
09:00
09:30
10:00
10:30
11:00
11:30
12:00
12:30
13:00
13:30
14:00
14:30
15:00
15:30
16:00
16:30
17:00
17:30
18:00
18:30
19:00
19:30
20:00
20:30
21:00
21:30
22:00
22:30
23:00
23:30