lab 9 work - ME 218 (17795) Alan Shu-Ming Kwok (sk25784)...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
ME 218 (17795) Alan Shu-Ming Kwok (sk25784) Lab 9 1. Write a simple program that performs the following pseudo-code: #include <iostream> #include <stdio.h> #include <math.h> using namespace std; #define PI 3.141592654 bool zipvalid( int zip) { int zip_prefix = 0; int exclusion[] = {0, 1, 2, 3, 4, 99, 213, 269, 343, 345, 348, 353, 419, 428, 429, 517, 518, 519, 529, 533, 536, 552, 568, 578, 579, 589, 621, 632, 642, 643, 659, 663, 682, 694, 695, 696, 697, 698, 699, 702, 709, 715, 732, 742, 771, 817, 818, 819, 839, 848, 849, 854, 858, 861, 862, 866, 867, 868, 869, 876, 886, 887, 888, 892, 896, 899, 909, 929, 987 }; zip_prefix = zip/ 100; for ( int i = 0; i<= 68; i++) { if (zip_prefix == exclusion[i]) { cout<< " Invalid Zip Code." << endl; return false ;} } if (zip_prefix < 0 || zip_prefix > 999) { cout<< " Invalid Zip Code." << endl; return false ;} cout << " Zip code is valid" <<endl; return true ; } double h( int zip) { int middle_digit = (zip/100) %10; if (middle_digit < 5) return 0.05; else if (middle_digit < 6) return 0.1; else return 0.2; } int panel( int zip) { int first_digit = zip/10000; int second_digit = (zip/1000) % 10; if (first_digit < second_digit) return 14; else if (first_digit == second_digit) return 16; else return 20; } int function_number( int zip) { int second_to_last_digit = ( zip%100 ) / 10; if (second_to_last_digit > 5) return 1; else if (second_to_last_digit >4)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/04/2011 for the course ME 218 taught by Professor Unknown during the Spring '08 term at University of Texas at Austin.

Page1 / 7

lab 9 work - ME 218 (17795) Alan Shu-Ming Kwok (sk25784)...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online