reset password
Author Message
Arnav98
Posts: 48
Posted 00:52 Mar 18, 2017 |

Did anyone figure out how to do these problems ? Tried everything but still couldn't do it.

Dtwayne13
Posts: 2
Posted 08:22 Mar 18, 2017 |

What have you tried? 

 

Both problems could be solved with less than 16 lines of actual code per problem.

 

Look at the hints. 

 

HINT: You will need nested loops for this one and will need to think creatively of how to use a string accumulator.

 

HINT: You will need to use nested loops for this one.  Each pattern is its own set of nested loops.

 

 

Last edited by Dtwayne13 at 08:23 Mar 18, 2017.
kknaur
Posts: 540
Posted 12:03 Mar 18, 2017 |

For problem 4, take a look at the star pattern from the end of the slides.  The idea is similar, but instead of printing the same amount of stars in each row, you are printing a different number in each row.  However, there is a pattern.  Experiment with changing the loops headers and see how the changes affect the output.

Arnav98
Posts: 48
Posted 12:53 Mar 18, 2017 |

How do we store different output for each literation in a for loop for question 3 so that we can print all the outputs at the end ?

kknaur
Posts: 540
Posted 12:55 Mar 18, 2017 |

The final output is one big string that I just print at the end.  Take a look at the subtraction quiz example... I did the same thing when printing the report of which questions were right and which were wrong.

KA1997
Posts: 31
Posted 22:44 Mar 18, 2017 |

The numbers part for #4 was easy to find out. But the letters part is challenging because it goes the other way around.

Any hints?

Arnav98
Posts: 48
Posted 22:47 Mar 18, 2017 |
KA1997 wrote:

The numbers part for #4 was easy to find out. But the letters part is challenging because it goes the other way around.

Any hints?

Try using the unicode value to obtain the required characters.

Arnav98
Posts: 48
Posted 22:50 Mar 18, 2017 |

Does anyone know how to make the alternate characters of the output in the last part of question 4 lowercase. I tried taking out each character based on its index and then convert the required characters to lower case but im getting weird outputs if I do that.

jzunig20
Posts: 38
Posted 02:04 Mar 19, 2017 |
Arnav98 wrote:

Does anyone know how to make the alternate characters of the output in the last part of question 4 lowercase. I tried taking out each character based on its index and then convert the required characters to lower case but im getting weird outputs if I do that.

the pattern is alternating right, so that means every other character is uppercase lowercase uppercase lowercase, if you think of numbers, what is the pattern in terms of numbers, starting with the uppercase being the first number lowercase second number

bliu14
Posts: 10
Posted 15:13 Mar 19, 2017 |

For Problem 03, is formatting necessary for Stores more than 10? Did anyone else aim to solve this problem, or is it unnecessary? I would likely need to use a printf or String.format. Screenshot attached for context.

Last edited by bliu14 at 15:14 Mar 19, 2017.
jzunig20
Posts: 38
Posted 15:29 Mar 19, 2017 |
bliu14 wrote:

For Problem 03, is formatting necessary for Stores more than 10? Did anyone else aim to solve this problem, or is it unnecessary? I would likely need to use a printf or String.format. Screenshot attached for context.

i believe the graphs should be dynamically generated based on user input, so if user enters 15 for stores, then only 15 stores should print out with the correct amount of * for each store

bliu14
Posts: 10
Posted 15:43 Mar 19, 2017 |
jzunig20 wrote:
bliu14 wrote:

For Problem 03, is formatting necessary for Stores more than 10? Did anyone else aim to solve this problem, or is it unnecessary? I would likely need to use a printf or String.format. Screenshot attached for context.

i believe the graphs should be dynamically generated based on user input, so if user enters 15 for stores, then only 15 stores should print out with the correct amount of * for each store

I know that graphs should be dynamically generated – I inputted 10 stores and 1000 sales for each. The screenshot is an example that shows how the display is offset when the variable for Store goes above two digits.

Arnav98
Posts: 48
Posted 16:00 Mar 19, 2017 |

I understand what you are trying to say but I saw the requirements of the question again and all it says is that output should be dynamically generated and doesnt talk about any need to use printf statement.

Last edited by Arnav98 at 16:01 Mar 19, 2017.
bliu14
Posts: 10
Posted 16:02 Mar 19, 2017 |

I see, that makes sense. Thanks!

jzunig20
Posts: 38
Posted 16:03 Mar 19, 2017 |

no mention about printf so you should be good, i understood something else from your question,