Preview

Exam Programer

Good Essays
Open Document
Open Document
1508 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Exam Programer
King Abdulaziz University
Faculty of Computing and Information Systems
Fall Term 2011/1432-1433

Course Code: CPCS-202 Course Name: Programming I
________________________________________________________________

Problem 1:

Write a program that asks the user to enter a favorite color, a favorite food, a favorite animal, and the first name of a friend or relative. The program should then print the following two lines, with the user’s input replacing the items in italics: I had a dream that Name ate a Color Animal and said it tasted like Food!

For example, if the user entered blue for the color, hamburger for the food, dog for the animal, and Jake for the person’s name, the output would be
I had a dream that Jake ate a blue dog and said it tasted like hamburger!
Don’t forget to put the exclamation mark at the end.

Notes:

This project requires careful attention to spaces in output messages. In particular, a space must be explicitly printed between the variables color and animal.

Solution:

Problem Analysis Chart:

Given Data | Required Results | namecoloranimalfood | Print “I had a dream that Name ate a Color Animal and said it tasted like Food!" | Processing Required | Solution Alternatives | System.out.println("I had a dream that " + name + " ate a " + color + " " + animal); System.out.println("and said it tasted like " + food + "!"); | |

Algorithm:

1. Read Name from user. 2. Read Color from user. 3. Read Animal from user. 4. Read Food from user. 5. Display message “I had a dream that Name ate a Color Animal and said it tasted like Food!"

Sample Code Solution:

From now on to the end of your four year program here at the University, every program you submit whether it is in lab or as homework should include the following: * File name * Full description of the coded program * Author: Name of student * Student ID * Student email address * Date submitted

/** File name:

You May Also Find These Documents Helpful

  • Satisfactory Essays

    Pt1420 Unit 7 Study Guide

    • 582 Words
    • 3 Pages

    10.Write a program to prompt the user to enter a line of text. On the next line display the capital letter that come first alphabetically and the one that comes last. If no capital letters…

    • 582 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    This is no dream about monsters under the bed... this is very different! It is the near future,on a deserted island in the Pacific Ocean, many people have heard of this so called beast and want to know what it is or what it means. Initially the beast represents fear. The beast is ever changing and has countless meanings and interpretations behind it.…

    • 323 Words
    • 2 Pages
    Good Essays
  • Good Essays

    Many different characters have dreams, and each responds differently to them. During the journey to the Crow Raid, White Man’s Dog has a dream about naked women desiring him, but fears danger if he goes. He wants to inform Yellow Kidney of this dream put hesitates due to advice he had received from his father. In the end this was a costly decision, as the dream comes to fruition during the raid, not White Man’s Dog, but for Yellow Kidney. Turns-out the alarm for risk was valid, as Yellow Kidney gets very sick from his encounter with the Crow Women. When news of White Mans Dog feels responsible[2] for this outcome. During this same raid, Fast Horse also has a dream. Fast Horse is prideful and boasts of his dream, which turned out to not come true. Fast Horse was greatly humiliated by this and seemed to have his future driven by…

    • 727 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Ap Psych Key Terms Chp 7

    • 741 Words
    • 3 Pages

    Dream- a sequence of images, emotions, and thoughts passing through a sleeping persons mind. Dreams are notable for their hallucinatory imagery, discontinuities and incongruities, and for the dreamer’s delusional acceptance of the content and later difficulties remembering it.…

    • 741 Words
    • 3 Pages
    Good Essays
  • Better Essays

    1. The animal imagery in the following excerpt is particularly strong. Based on this imagery, what do you think is the significance of the title of this…

    • 1239 Words
    • 5 Pages
    Better Essays
  • Good Essays

    As I observed his ghastly shadow I saw that he was over 8 feet tall. He had huge claws so each on looked like a dagger itself, ripping and tearing at the flesh of my fellow companions. He had long horns that curled inwards like a rams horns. He had a long, scaly like tail that swung and whipped in the air followed by a flop on the ground in a joyless motion, as if it too, like the monster, was thrilled to taste the succulent human blood flowing over the tongue and trickling down the throat.…

    • 594 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Alexie Monologue

    • 772 Words
    • 4 Pages

    “Back again it looks like I’m gonna be here all night. Looks like a long night.” I say to my dog Alexie. But it is going to be worse than that. I picked up the phone and ordered a pizza. “Yes I’ll like a meat lovers pizza with pineapple on it” I say. When the pizza came I took a bite and……

    • 772 Words
    • 4 Pages
    Good Essays
  • Good Essays

    Sometimes animals are replaced by humans to connect with the reader. In the Story Night Calls by Lisa Fugard, at first her story was about two Japanese birds but in the end she replaced the bird with a human character. Lisa Fugard creates a somber mood in “Night Calls” through imagery, figurative language, and the creation of mood. With the somber mood it made the story very interesting to read.…

    • 345 Words
    • 2 Pages
    Good Essays
  • Good Essays

    “Dreams of the Animals” by Margaret Atwood represents the nature of animals’ dreams. They mostly dream of other animals “each according to its kind”, moles dream of “mole smells”, and frogs dream of “green and golden/ frogs”. The word “mostly” is used here. Why? That’s because there are exceptions. The poem later states that “certain mice and small rodents/ have nightmares of a huge pink/ shape with five claws descending”. The word “nightmare” doesn’t only mean a bad dream when sleeping, but also something (as an experience, situation, or object) having the monstrous character of a nightmare or producing a feeling of anxiety or terror, according to Merriam-Webster’s Dictionary. Therefore, it might also means that mice and small rodents are afraid of “a huge pink/ shape with five claws descending”. What is “a huge pink/ shape with five claws”? This is a question. However, the poem continues with red and black striped fish’s and birds’ dreams which are different. The dreams of moles and frogs are simple, but “red and black/ striped fish” and “birds” also dream of something more complex. The fish dream of “defense, attack meaningful/ patterns” and the birds dream of “territories/ enclosed by singing”. Why are their dreams different? Two questions are waiting to be answered.…

    • 384 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    4. While Keshawn and his mother are looking at a book together, Keshawn's mother shows him a picture of an animal and says, "Cow." Keshawn says, "cow," and his mother praises him for his correct utterance. Two pages later, Keshawn spontaneously points to a picture and correctly identifies it as a cow.…

    • 381 Words
    • 1 Page
    Satisfactory Essays
  • Powerful Essays

    speech ‘ I have a dream’ and since, then it has travelled through millions of heads and…

    • 3853 Words
    • 16 Pages
    Powerful Essays
  • Good Essays

    No Idea

    • 445 Words
    • 2 Pages

    9. If you were to think of animals in the following description of Harry and Ganderbai, of what would you think:…

    • 445 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    Kite Runner Essay Example

    • 399 Words
    • 2 Pages

    CD2- Introduction of the dream Hassan had. "There was a monster in the lake. It had grabbed Hassan by the ankles, dragged him to the murky bottoms. I was that monster" (86).…

    • 399 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    In the essay, “Am I Blue?” by Alice Walker, Walker discusses the emotions that animals have and the similarities that those emotions have to human emotions. In this way, Walker is comparing her emotions, as a human, to the emotions of a horse (Blue). Walker uses imagery to portray this comparison.…

    • 441 Words
    • 2 Pages
    Good Essays
  • Good Essays

    A Strange Day in July

    • 479 Words
    • 2 Pages

    Slowly he awakened taking in his surroundings. Above him was a dim green light dangling from the low red veined ceiling. He was lying on a table, with the same color scheme, in his school clothes. He could faintly hear some kind of chattering in an unknown language, but he could not pinpoint the sound. So, he laid there wondering what was happening and where he was. He was thinking that maybe there was lave in the red veins, when suddenly a creature appeared out of nowhere. It was tall, green and looked like it was slimy to the touch. When it walked its feet sounded like suction cups on the ground. Its big black eyes were staring him down as it reached…

    • 479 Words
    • 2 Pages
    Good Essays