Giter VIP home page Giter VIP logo

firstio's Introduction

In this lab, we will practice getting input from the user as well as showing them output. We will also start using variables.

The purpose of the program will be to allow the user to set an alarm so that it looks like:

Set your alarm.
Hour:
8
AM or PM (enter A or P):
P
Give a one-word alarm title:
School
School alarm has been set for 8 AM

In this example, the user typed in the responses:

8, P, and School

First, identify what data type is most appropriate to store each of those three pieces of information: a whole number, a letter, and a word.

Declare three variables to store those and make sure to give them meaningful names.

Next, display the message Set your alarm. followed by an end of line.

At this point, check to see if there are any errors and if it displays it similar to the first line of the above example. To do so, first compile your code (to see if the code is grammatically correct) by typing this in the terminal:

g++ main.cpp --std=c++17

If it gives you any errors, read them and try to fix them in your code (before saving and compiling again). If it does not give any errors, then it has compiled successfully! You should then see a file called a.out. To run your program, type this in the terminal:

./a.out

Once you have that working, continue to build the user interaction:

  1. Prompt for the hour
  2. Have the user input their hour and store it in the appropriate variable
  3. Prompt for AM/PM
  4. Have the user input A or P and store that in the appropriate variable
  5. Prompt the user for an alarm title
  6. Have the user input the title and store that in the appropriate variable

Compile and run it and type the user input yourself to test that it works.

Finally, output the message School alarm has been set for: and then display...

  1. the variable storing the hour,
  2. a literal space (" ")
  3. the variable storing either A or P
  4. a literal letter M ("M")
  5. an end of line

Again, compile and run it and check to see what it does, compared to what was expected.

firstio's People

Contributors

kbuffardi avatar

Watchers

 avatar

firstio's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.