Roman Numeral to Decimal

Problem:
Write a program that converts a number entered in Roman numerals to a
positive integer. Your program should consist of a class, say, romanType.
An object of type romanType should do the following:
a. Store the number as a Roman numeral.
b. Convert and store the number as a positive integer.
c. Print the number as a Roman numeral or positive integer as requested
by the user.

The integer values of the Roman numerals are:
M 1000
D 500
C 100
L 50
X 10
V 5
I 1
d. Test your program using the following Roman numerals: MCXIV,
CCCLIX, MDCLXVI.

See program here:

Welcome to the Rodeo Café

Problem: Write a program to help a local restaurant automate its breakfast billing system. The program should do the following:
a. Show the customer the different breakfast items offered by the restaurant
b. Allow the customer to select more than one item from the menu
c. Calculate and print the bill. Assume that the restaurant offers the following breakfast items (The price of each item is shown to the right of the item):

Plain Egg $1.45
Bacon and Egg $2.45
Muffin $0.99
French Toast $1.99
Fruit Basket $2.49
Cereal $2.49
Coffee $0.50
Tea $0.75

Use an array, menuList, of the struct menuItemType, as defined in Programming Exercise 2. Your program must contain at least the following functions:

– Function getData: This function loads the data into the array menuList.
– Function showMenu: This function show the different items offered by the restaurant and tells the user how to select the items.
– Function printCheck: This function calculates and prints the check. (Note that the billing amount should include a 5% tax.)
A sample output is:

Welcome to Johnny’s Restaurant
Bacon and Egg $2.45
Muffin $0.99
Coffee $0.50
Tax $0.20
Amount Due $4.14

Format your output with two decimal places. The name of each item in the output must be left justified. you may assume that the user selects only one item of a particular type.

See program below:

Election Results

Can you feel the Bern!?

Problem: Write a program that allows the user to enter the last names of five candidates in a local election and the number of votes received by each candidate. The program should then output each candidate’s name, the number of votes received, and the percentage of the total votes received by the candidate. Your program should also output the winner of the election.

Post Office Zip Code bars

Problem: For faster sorting of letters, the United States Postal Service encourages companies that send large volumes of mail to use a bar code denoting the ZIP code. The encoding scheme for a five-digit ZIP code is show in Table 1. There are full-height frame bars on each side. The fie encoded digits are followed by a correction digit, which is coputed as follows: Add up all digits, and choose the correction digit to make the sum a multiple of 10. For example, the zip code 95014 has sum of digits 19, so the correction digit is 1 to make the sum equal to 20.

Each digit of the zip code, and the correction digit, is encoded according to Table 1, where 0 denotes a half bar and 1 a full bar. Note that they represent all combinations of two full and three half bars. The digit can be easily computed from the bar code. For example, 0110 is 0 x 7 + 1 x 4 + 1 x 2 + 0 x 1 + 0 x 0 = 6. The only exception is 0, which would yield 11 according weight formula.

Table 1:
1 00011
2 00101
3 00110
4 01001
5 01010
6 01100
7 10001
8 10010
9 10100
0 11000

Write a program that asks the user for a zip code and prints the bar cod. Use : for half bars, | for full bars. For example, 95014 becomes

||:|:::|:|:||::::::||:|::|:::|||

Where the first and last bar represent frame bars. The general format is:

Frame-bar, digit1, digit2, digit 3, digit 4, digit 5, check-digit, Frame-bar

See program below for solution:

Python Installation

Everyone’s favorite serpentine language (sorry Slytherin) can be installed on Mac. Thissssss is how I did it.

1. You’ll need a text editor. There are many out there, but I selected one that works on Mac, Windows, and Linux. I chose Atom which I downloaded from their website https://atom.io

2. You’ll need to download Python

3. You’ll need an IDE to edit and run your program. There are many out there. When I heard of Spyder’s science and data analysis libraries, I thought I’d give it a shot. I’ll be running the program below in the terminal.

 

To Install Python do the following:

  1. Open a terminal window
    • Mac comes with a pre-installed version of Python 2.x.xx
    • Check this by entering the following command
       python --version 
  2. To install Python 3 go to their official page (python.org/downloads) and select the download button
  3. Open the .pkg download and run through the installation widget.
    • Once completed use the following in the command in the terminal to verify installation
       python3 --version 

 

Write and run a program

  1. Open Atom text editor
  2. Type
 print('hello world') 
  1. Save the file with any name and the python file extension. For example Hello.py
  2. Run from the terminal
    • Ensure you’re in the directory where your file was saved
    • Run the program using the following command in the terminal based on the name the file was saved as.
 python3 hello.py 

Mobile Automation Testing: Appium Installation for Mac

  1. Install Xcode
    • Check for iOS Simulator version in Xcode
  2. Install Java (JDK)
    • Verify installation in Terminal with following command
      • java -version
      • If version number appears, then it is installed
  3. Install Eclipse IDE for Java EE Developers
    • Ensure Java is installed or Eclipse will not run
  4. Download Appium Server / Jars from MVN repository
  5. Download Selenium Jars

Mobile Automation Testing: Appium: Guts and Glory

Appium follows client/server architecture. It’s a webserver that exposes REST API

  1. It received connection from a client, listens for commands, executes those commands on a mobile device and responds with HTTP representing the results of the command execution

Clients initiate a session with a server in ways specific to each library, but they all end up sending a POST/session request to the server, with a JSON object called the ‘desired capabilities’ object. At this point the server will start up the automation session and responds with a session ID which is used for sending further commands.

Desired capabilities are a set of keys and values (i.e. a map or hash)) sent to the Appium server to tell the server what kind of automation session we’re interested in starting up

  1. There are various cababilites which can modify the behavior of the server during automation (examples…)
    • We might set the ‘platformName’ capability to iOS to tell Appium that we want an ‘iOS’ session, rather than an Android one
    • Or we might set the ‘safariAllowPopups’ capability to ‘true’ in order to ensure that, during a Safari automation session, we’re allowed to use Javascript to open up new windows
    • The complete list of capabilities is in Appium’s documentation

Appium is a server written in Node.js. It can be built and installed from source or installed directly from NPM.

Appium has client libraries (in Java, Ruby, Python, PHP, Javascript, and C#) which support its extensions to the WebDriver protocol. When using Appium, you want to use these client libraries instead of regular WebDriver client ones.

There exist GUI wrappers around the Appium server that can be downloaded. These come bundeled with everything required to run the Appium server, so you don’t need to worry about Node. They also come with an Inspector, which enables you to check out the hierarchy of your app. This can come in handy when writing tests.

Mobile Automation Testing: Next Thing Next: Why Appium?

Appium is an open source, cross-platform test automation tool for native, hybrid, and mobile web pages, tested on simulators (iOS, FirefoxOS), emulators (Android), and real devices (iOS, Android, FirefoxOS).

The supported platforms are those that can be tested on using simulators, emulators, and real devices i.e.:

  1. iOS
  2. Android OS
  3. Firefox OS

So why Appium?

  1. You don’t have to recompile your app or modify it in any way, due to use of standard automation APIs on all platforms
  2. You can use any testing framework
  3. You can write the code in any language supported by Webdriver

If you use Apple’s UIAutomation library without Appium you can only write tests using Javascript and you can only run testes through the instruments application. Similarly, with Google’s UIAutomator you can only write tests in Java. Appium opens up the possibility of true cross-platform native mobile automation.

Mobile Automation Testing: First Thing First: What is Appium?

I’m currently on an adventure to learn automation. Tuck and roll with me as I learn and troubleshoot the framework as well as write scripts.

First couple of things I’ve learned so far and will be doing are:

  1. Appium is a open source mobile automation testing tool for Android and iOS application for both Native, Hybrid, and mobile web apps. It supports Selenium Web Driver API.
  2. Selenium and one of the supported languages (Java, C#, Javascript, Python, Ruby) is needed to learn Appium.
  3. I’ll be developing, architecting, and designing a mobile automation framework which my Appium test cases will be imported into.
  4. IDE’s for writing Java are Eclipse, IntelliJ, and Android Studio.

Food for thought. Or not.