Write a program that reads a string and outputs the number

Write a program that reads a string and outputs the number of times each lowercase vowel appears in it. The program must contain a function with one of it’s parameters as a string variable and return the number of times each lowercase vowel appears in it. Also please write a program to test your function.

Write a program that reads a string and outputs the number

Need Solution Email me at: Topsolutions8@gmail.com

or

https://gum.co/LGKxz

week 6 problem 2

 

NOTE: Remember that you are NOT allowed to use the break, return, or exit statements to exit from a loop. All loops must exit ONLY via their test condition.

 

Program #2

Mathematically, given a number , we can define a sequence , , … where is the sum of the squares of the digits of . nis happy if and only if there exists isuch that .

Here is an example:

First, take each digit of any positive integer, square them and add them together. We will use the number nineteen as an example:

19 à 12 + 92 = 82

Then take each digit of this number, square them and add them together:

82 à 82 + 22 = 68

And repeat until the result is 1:

68 à 62 + 82 = 100

100 à 12 + 02 + 02 = 1

So when the sum of the squares of the digits in the last member in the sequence starting with n eventually reduces to 1, n is happy.

Additionally:

If a number is happy, then all members of its sequence are happy. If a number is unhappy, all members of its sequence are unhappy.

The above example sequence: 19, 82, 68, 100 is happy, and so all of the terms within the sequence are also happy.

Write a program that determines which numbers produce a happy sequence, within a series of test numbers.

The user will provide a first number to test and a last number to test. The program will test the numbers starting with the first number, incrementing by one, and repeating until the last number.

Program Implementation Requirements:

  1. Tell the user what the program does before prompting for input.

 

 

  1. mainwill call a user-defined function to read the first and last numbers for the range to test from the user.

 Theuser-defined function will:

oSeparately read and validate each number. Both the first and last numbers must be at least 1 and can be up to 9999 (remember to define constants for these values!)

  • If the first number is not in the correct range, issue an error message and then re-prompt until the number entered is valid.

oThe last number cannot be smaller than the first number.

  • If the last number is not in the correct range or is smaller than the first number, issue an error message and then re-prompt until the number entered is valid.

oPass back both values to main using reference parameters.

  1. mainwill start with the first number as the test number, and loop until all numbers including the last number have been tested. Each time the loop runs, main will:

oCall a user-defined function to test if the number is happy.

oDisplay the results (whether the sequence is happy or unhappy), and pause so the results can be read by the user.

oIncrement the test number.

 Theuser-defined function to test whether a number is happy must implement nested loops, as follows:

oA test number will be passed into the function.

oThe function’s outer loop will test the number, as follows:

oUse an inner loop to compute the sum of the squares of the digits in the current term. NOTE: You must use a loop, so this program will still work for larger numbers, if the maximum value of the last number constant is modified.

oCount and display each term.

oEach term displayed should be formatted to a width of 8, and 10 terms should be displayed per line.

oRepeat with the sum of the squares of the digits in the current term becoming the next term to test, until it is determined:

  • The test number is happy (when the sum of the square of the digits is 1)
  • The test number is unhappy (when 50 terms have been computed, without reaching 1).

oAfter the outer loop exits, the function shall display the number of terms in the sequence.

oA booleanvalue will be returned to main, indicating whether the displayed sequence is happy or not.

 

Program to test for Happy numbers

Enter the first number to test: 79

Enter the last number to test: 1

Invalid — must be between 79 and 9999. Try again.

Enter the last number to test: 82

Test sequence for 79 is:

79 130 10 1

4 sequence terms computed

The above sequence of numbers is happy

Press any key to continue . . .

Test sequence for 80 is:

80 64 52 29 85 89 145 42 20 4

16 37 58 89 145 42 20 4 16 37

58 89 145 42 20 4 16 37 58 89

145 42 20 4 16 37 58 89 145 42

20 4 16 37 58 89 145 42 20 4

50 sequence terms computed

The above sequence of numbers is unhappy

Press any key to continue . . .

Test sequence for 81 is:

81 65 61 37 58 89 145 42 20 4

16 37 58 89 145 42 20 4 16 37

58 89 145 42 20 4 16 37 58 89

145 42 20 4 16 37 58 89 145 42

20 4 16 37 58 89 145 42 20 4

50 sequence terms computed

The above sequence of numbers is unhappy

Press any key to continue . . .

Test sequence for 82 is:

82 68 100 1

4 sequence terms computed

The above sequence of numbers is happy

Press any key to continue . . .

Testing of numbers 79 to 82 complete.

 

NOTES:

oIf the first and last numbers are the same, and only the first number will be tested.

oFor testing purposes, it may help to know that the happy numbers up to 100 are:

 

1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49, 68, 70, 79, 82, 86, 91, 94, 97, 100

Program and Function Documentation (both programs)

1) Include top of program comments as specified in course Content section 1.8.

2) Comment any constants/variables whose names are not completely descriptive.

3) Include prototypes for all of your user-defined functions. The prototypes should be placed above main, and the function definitions should be placed below main.

4) Provide a comment above each user-defined function definition that includes:

oDividing lines

oA description of what the function does

oThe name and a description of each input parameter, used to pass values into the function

oThe name and a description of each output parameter, used to pass values back from the function

oThe name (if there is one), and a description of what is returned from the function via the return statement (if anything).

 

Examples:

// ———————————————————-

// Task: Reads a positive and negative number from the user

// and error checks them

// Input parameters: prompt – prompt to display

// Output parameters: posValue, negValue – valid numbers read

// ———————————————————-

voidgetData (string prompt, int&posValue, int&negValue)

 

week 6 problem 2

Need Solution Email me at: Topsolutions8@gmail.com

or

https://gum.co/BvTDU

 

 

pseudocode combining a and b and Data directory

pseudocode data dictionary, hierarchy, and flowchart.
a. The No Interest Credit Company provides zero-interest loans to customers. Design an application that gets customer account data, including an account number, customer name, and balance due. Output the account number and name, then output the customer’s projected balance each month for the next 10 months. Assume that there is no finance charge on this account, that the customer makes no new purchases, and that the customer pays off the balance with equal monthly payments, which are 10 percent of the original bill.
b. Modify the No Interest Credit Company application so it executes continuously for any number of customers until a sentinel value is supplied for the account number.

pseudocode combining a and b and Data directory

Need Solution Email me at: Topsolutions8@gmail.com

or

https://gum.co/ggGDF

 

 

Jason has opened a coffee shop at the beach and sells coffee

Jason has opened a coffee shop at the beach and sells coffee in three sizes: small (9oz) medium (12oz) and large (15oz). Small cost is $1.75 medium costs $1.90 and large costs $2.00. Write a menu driven program that will make the coffee shop operational. The program should allow the user to do the following:

1. buy coffee in any size and any number of cups.
2. at any time show the total number of cups of coffee of each size sold.
3. At any time show the total amount of coffee sold.
4. at any time show the total amount of money made.

The program should at the least:
1. a function to show the user how to use the program.
2. a function to sell coffee.
3. a function to show the number of cups of each size sold.
4. a function to show the total amount of coffee sold.
5. a function to show the total amount of money made.

No global variables. Special values such as coffee cup sizes and cost of a coffee cup must be declared as named constants. 

Jason has opened a coffee shop at the beach and sells coffee

Need Solution Email me at: Topsolutions8@gmail.com

or

https://gum.co/cEUT

 

 

DATA vector

Assignment 6 – Object Oriented Programming

 

1 Managing Dynamic Arrays

Managing dynamically sized arrays can be a pain while dealing with memory on the heap. Memory

leaks, dangling pointers, etc can lead to invalid memory accesses/segmentation faults that halt your

program abruptly. Your task is to design a DataVector class that encapsulates the implementation

of a dynamically sized double array. The interface should be such that the users of your class should

not be exposed to the underlying implementation details such as memory allocation (new), release

(delete), resize, etc. Your DataVector class must have the following public interface. The difficulty

levels are marked as L1, L2 and L3, going from easy to hard.

1. DataVector ( ) ; //L2

This is the default constructor with no parameters. By default, this allocates space for a

double array of size 10 and assigns a default value of 0 to each of them.

2. DataVector ( unsigned int i n i t S i z e , double ini tVa lue ) ; //L2

This is another constructor of the class that takes in arguments and allocates space for a

double array of size initSize and assigns a default value of initValue to each of them.

3. ~DataVector ( ) ; //L2

This is the destructor that does any cleanup necessary such as releasing all the memory on

the heap using the delete operator.

4. void Pr int I t ems ( ) ; //L2

This prints all the items in a single line and successive items are separated by a single space.

After the last item there should be a space and a newline character.

5. unsigned int GetSize ( ) ; //L1

This should return the current size of the double array.

6. void Reserve ( unsigned int newSize ) ; //L3

This function should increase the size of the array to newSize. Note that you would have to

allocate a fresh double array, to which you will have to copy the items from the old double

array, and then release the memory for the old double array. If newSize is less than the old

size, then you copy just the
rst newSize items from the old array. If newSize is greater than

the old size, then you copy all items from the old array.

 

7. double GetItemAt ( unsigned int index ) ; //L1

This returns the item at the speci
ed index. Assume index is in the range 0 to GetSize() – 1.

8. void SetItemAt ( unsigned int index , double val ) ; //L1

This sets the item at the speci
ed index to val. Assume index is in the range 0 to GetSize()

- 1.

9. double GetSum( ) ; //L2

This returns the sum of all items.

Note that you must use new and delete to manage the double array internally. All pointers,

counters, etc for the array bookkeeping must be made private in your class.

2 Grade Management

Now you will apply your DataVector class to manage the student grades of CS31. You will

implement a GradeManager class that internally uses an array of DataVector objects, that

were created dynamically using the new operator, to record the homework grades for a set of

students. Again, the idea is to encapsulate the underlying implementation such that the user of

GradeManager will not know that DataVector is being used internally. Your GradeManager

class must have the following public interface:

1. GradeManager ( unsigned int nStudents , unsigned int nHWs ) ; //L3

This is the only constructor of the class, and it speci
es the number of students nStudents

and number of homeworks nHWs for the class. You should use these to dynamically set the

array sizes. Also, if nStudents is 100 then the student IDs will range from 0 to 99. Similarly,

if nHWs is 10 then the homework IDs will range from 0 to 9.

2. ~GradeManager ( ) ; //L2

This is the destructor that does any cleanup necessary such as releasing all the memory on

the heap using the delete operator.

3. void Pr intGrades ( ) ; //L2

This prints all the homework grades for all students. Each student’s grades are printed on a

separate line, and the successive homework grades of each student are separated by a single

space. After the last grade on a line, there should be a space and a newline character.

4. unsigned int Ge tClas sSi z e ( ) ; //L1

Returns the number of students.

5. unsigned int GetHWCount ( ) ; //L1

Returns the number of homeworks.

6. void SetGrade ( unsigned int sID , unsigned int hwID , double val ) ; //L2

This sets the grade of student sID to val for the homework hwID.

7. double GetGrade ( unsigned int sID , unsigned int hwID) ; //L2

This returns the grade of student sID for the homework hwID.

8. double GetTotalScoreForStudent ( unsigned int sID ) ; //L2

This returns the sum of the respective student’s scores on all homeworks.

9. double GetTotalScoreForStudentWithDrop2Least ( unsigned int sID ) ; //L3

This returns the sum of the respective student’s scores on all homeworks except the least 2

homeworks. Henceforth, this is referred to as the Drop2 policy.

10. unsigned int GetBestStudent ( ) ; //L2

This returns the sID of the student who has the best total score across homeworks with the

Drop2 policy.

11. unsigned int GetNumStudentsInRange ( double low , double high ) ; //L3

This returns the number of students whose total homework scores (with Drop2 policy) lie in

the range low <= totalscore < high. (Including low and excluding high).

12. double GetClassAverage ( ) ; //L2

This returns the average of the total homework scores (with Drop2 policy), across all students.

13. double GetClassSTD ( ) ; //L2

This returns the population standard deviation of the total homework scores (with Drop2

policy), across all students. The standard deviation of a set of n total scores t1; t2; t3:::tn

whose average is m, is given by,

2

r

(t1 􀀀 m)2 + (t2 􀀀 m)2 + (t3 􀀀 m)2 + :::: + (tn 􀀀 m)2

n

You can use the standard library sqrt() function from cmath header to
nd the square root.

3 Dos/Donts/General Advice

1. All your code should be written inside the two classes DataVector and GradeManager.

It is recommended that you do not modify anything outside these classes (main() function

especially). But if you really want to write your own test cases in the main() function, then

it is your responsibility to revert those changes before submitting on the server.

2. A set of basic tests that call into the public inferface on the 2 classes is given to you in the

main() function. These tests might not be complete, and if your output matches the output

given at the end of this document, then it does not necessarily mean that you will get full

credit on the assignment. We will be designing new test cases for grading purposes, and hence,

it is your responsibility to make sure the implementation works as expected. Nevertheless,

these tests may give you some ideas on how to use the public interface.

3. It is recommended to start implementing the easy functions
rst. You can also follow the

order listed above. This order will help you build the class one step at the time, and some of

the earlier functions can be called/reused in later functions if needed.

4. Reusability is one of the main objectives of Object Oriented Programming. So, feel free to

reuse any function/code you might have already written.

5. You might run into Segmentation Faults (a.k.a SIGSEGV on unix systems), or Invalid memory

access/Bad access or Protection faults, or any kind of memory corruption issues. If you do,

then the following checks might help.

Check if your indexes to the dynamically allocated arrays are within the legal range. For

example, if you allocated a 10 element double array using the syntax new double[10],

then make sure your index values to this array are in the range 0 􀀀 9.

Check if you have any dangling pointers. These are pointers that hold addresses to

memory that have already been released using the delete operator. It is usually a good

practice to set your pointer to NULL after you have called delete on it. For example,

delete [ ] pt r ;

pt r = 0 ;

Check if you are dereferencing a NULL pointer.

4 What to turn in

Guidelines on where to submit the project will be available 48 hours before the assignment. Your

submission
le must be in the following format: the completed oop.cpp must be compressed into a

single .zip
le. The ZIP
le name must be in the following format:

StudentID_proj6.zip

For instance if my student ID is 123456789 and I am submitting my solution for assignment 6,

then I am going to compress oop.cpp
le and rename the zip
le to:

123456789_proj6.zip

You should only include the oop.cpp
le that you modi
ed into the zip
le. Do not submit/in-

clude any other
le such as the executable or the contents of the debug folder. Same as other

assignments, a good sanity check is to check your zip
le for corruption by extracting it and testing

whether it did compress it successfully.

5 Solution Output

After implementing the above 2 classes, the given main() function in oop.cpp should output the

following. This is also contained in the sampleout.txt text
le given to you with the starter code.

DataTest 1

0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

DataTest 2

3.56 3.56 3.56 3.56 3.56 3.56 3.56 3.56 3.56 3.56 3.56 3.56 3.56 3.56

DataTest 3

130

DataTest 4

17

5

3.56 3.56 3.56 3.56 3.56

DataTest 5

3.56 3.56 3.56 3.56 3.56 1.11 3.56 3.56 3.56 3.56 3.56 3.56 3.56 3.99 5.66

DataTest 6

88.50

GradeTest 1

10 9

GradeTest 2

0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

GradeTest 3

67.00 34.00 56.00 64.00 87.00

78.00 66.00 91.00 79.00 90.00

45.00 59.00 91.00 99.00 100.00

70.00 73.00 54.00 89.00 33.00

89.00 81.00 67.00 95.00 98.00

GradeTest 4

67.00 34.00 56.00 64.00 87.00

78.00 66.00 91.00 79.00 90.00

45.00 59.00 91.00 99.00 100.00

70.00 73.00 54.00 89.00 33.00

89.00 81.00 67.00 95.00 98.00

GradeTest 5

308.00 218.00

404.00 260.00

394.00 290.00

319.00 232.00

430.00 282.00

2

GradeTest 6

[0.00,50.00] – 0

[50.00,100.00] – 0

[100.00,150.00] – 1

[150.00,200.00] – 1

[200.00,250.00] – 1

[250.00,300.00] – 2

GradeTest 7

4

247.45

21.63

 

DATA vector

Need Solution Email me at: Topsolutions8@gmail.com

or

https://gum.co/NnCMp

AccountsInheritanceHierarchy

Your company is ready to market their ability to sell goods. You will need to create a graphic that includes a business logo and a dollar amount of current sales. Your logo must include at least 1 shape, defined by a geometric path, using class GeneralPath, and the name of your business. Although the logo may be a compilation of shapes, including basic shapes provided by the Graphics class (i.e., rectangle, polygon, oval, arc or line), the logo must contain at least 1 shape that is not a basic shape and the name of the business. You want to impress your customers; therefore, your logo will flash on and off at a smooth rate, like a neon sign.

Current dollars in goods sold this year should also be displayed in the graphic. Your application will use the Accounts inheritance hierarchy designed previously to compute the total of goods sold. There are 3 types of sales accounts that track sales for your company: supplies, services, and paper.

Each sales account has its own formula for computing the current sales:

Supplies = office supplies sold dollar amount + books sold dollar amount + apparel sold dollar amount
Services = number of hours * rate per hour
Paper = number of pounds * price per pound
Intermediate-level Java programming should be demonstrated in your application:

There should be implemented constructors for each class.
The toString() method should be overridden to provide readable string representation of each object.
Getters and setters need to be implemented to enforce data hiding.
Code should be fully commented.
Program flow should be logical.
Behavior should be encapsulated into methods avoiding all encompassing large main() methods.
Projects should be developed in NetBeans and zipped prior to submission.
Code should compile and run free of exceptions, indicating that debugging tools were used to eliminate any run time errors.
Please add the pseudocode

AccountsInheritanceHierarchy

Need Solution Email me at: Topsolutions8@gmail.com

or

https://gum.co/xSYFx

 

 

Write a Java application that effectively uses

Write a Java application that effectively uses Java collections to store up to 20 instances of the Person class and its subclasses. Then write a GUI that displays the Person names using radio buttons to select a value. When a name is selected, a TextArea of the GUI should display the information about the selected Person.

Write a Java application that effectively uses 30

Need Solution Email me at: Topsolutions8@gmail.com

or

https://gum.co/iBmu