Search This Blog

Thursday, March 24, 2011

Visual Basic Program to Display the Number of Days in a Month

Write a program with a List Box that displays the months. When a month is selected, it should display the days in the month. The program should look like this: (Click to enlarge)















Here is the code:

Public Class MonthDay
    'Declare global variables
    Dim Jan As String = "31"
    Dim Feb As String = "28 or 29"
    Dim Mar As String = "31"
    Dim Apr As String = "30"
    Dim May As String = "31"
    Dim Jun As String = "30"
    Dim Jul As String = "31"
    Dim Aug As String = "31"
    Dim Sep As String = "30"
    Dim Oct As String = "31"
    Dim Nov As String = "30"
    Dim Dec As String = "31"

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        'Exit and close program
        Me.Close()

    End Sub


    Private Sub MonthDay_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.listMonth.Items.Clear()

        'Add items to listbox
        listMonth.Items.Add("January")
        listMonth.Items.Add("February")
        listMonth.Items.Add("March")
        listMonth.Items.Add("April")
        listMonth.Items.Add("May")
        listMonth.Items.Add("June")
        listMonth.Items.Add("July")
        listMonth.Items.Add("August")
        listMonth.Items.Add("September")
        listMonth.Items.Add("October")
        listMonth.Items.Add("November")
        listMonth.Items.Add("December")

    End Sub


    Private Sub listMonth_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles listMonth.SelectedIndexChanged


        'Display # of days in January if selected in label below the listbox
        If listMonth.Text = listMonth.Items(0) Then
            lblDays.Text = Jan
        ElseIf listMonth.Text = listMonth.Items(1) Then
            lblDays.Text = Feb
        ElseIf listMonth.Text = listMonth.Items(2) Then
            lblDays.Text = Mar
        ElseIf listMonth.Text = listMonth.Items(3) Then
            lblDays.Text = Apr
        ElseIf listMonth.Text = listMonth.Items(4) Then
            lblDays.Text = May
        ElseIf listMonth.Text = listMonth.Items(5) Then
            lblDays.Text = Jun
        ElseIf listMonth.Text = listMonth.Items(6) Then
            lblDays.Text = Jul
        ElseIf listMonth.Text = listMonth.Items(7) Then
            lblDays.Text = Aug
        ElseIf listMonth.Text = listMonth.Items(8) Then
            lblDays.Text = Sep
        ElseIf listMonth.Text = listMonth.Items(9) Then
            lblDays.Text = Oct
        ElseIf listMonth.Text = listMonth.Items(10) Then
            lblDays.Text = Nov
        ElseIf listMonth.Text = listMonth.Items(11) Then
            lblDays.Text = Dec
        End If

    End Sub
End Class

Tuesday, March 22, 2011

Visual Basic - 3-Digit Splitter Program


Write a program to convert a three-digit number into the number of hundreds, tens and ones in the
number.

You must use integer division and mod in the calculations.

The input should be a three digit number and the output should be the number of hundreds, the number of tens and the number of ones.

The output will look like this: (Click to enlarge)
Here is the code:


'Write a program to convert a three-digit number into the number of hundreds, ‘tens and ones in the number.  You must use integer division and mod in the ‘calculations. The input should be a threedigit number and the output should ‘be the number of hundreds, the number of tens and the number of ones.

Public Class frmSplitter


    Private Sub btnSplit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSplit.Click

        ' Declare and associate variables
        Dim Entry As Integer ' variable to hold Number entered
        Dim Hundreds As Integer ' variable to hold Hundreds calculation result
        Dim Tens As Integer ' variable to hold Tens calculation result
        Dim Ones As Integer ' variable to hold Ones calculation result

        ' Assign values from user input and associate objects with variables
        Entry = Val(txtEntry.Text)
        Hundreds = Val(lblHundreds.Text)
        Tens = Val(lblTens.Text)
        Ones = Val(lblOnes.Text)

        ' Calculate the results
        Hundreds = Entry - (Entry Mod 100)
        Ones = Entry Mod 10
        Tens = (Entry Mod 100) - Ones

        ' Display the results in the provided labels
        lblHundreds.Text = Hundreds
        lblTens.Text = Tens
        lblOnes.Text = Ones

    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        ' Exit the program and close the form
        Me.Close()

    End Sub
End Class

C++ Overloaded Hospital


Overloaded Hospital

Write a program that computes and displays the charges for a patient’s hospital stay. First, the program should ask if the patient was admitted as an in-patient or an out-patient. If the patient was an in-patient the following data should be entered:

·         The number of days spent in the hospital
·         The daily rate
·         Charges for hospital services (lab test, etc.)
·         Hospital medication charges

If the patient was an out-patient the following data should be entered:

·         Charges for hospital services (lab tests, etc.)
·         Hospital medication charges

The program should use two overloaded functions to calculate the total charges. One of the functions should accept arguments for the in-patient data, while the other functions accepts arguments for out-patient data. Both functions should return the total charges.

Input validation: Do not accept negative numbers for any information.

Here is what the output will look like: (Click to enlarge)
Here is the code:


// Kim Pestana, Chap. 6, Overloaded Hospital
// Write a program that computes and displays the charges for a patient’s hospital stay.
// First, the program should ask if the patient was admitted as an in-patient or an
// out-patient. If the patient was an in-patient the following data should be entered:
//     • The number of days spent in the hospital
//     • The daily rate
//     • Charges for hospital services (lab test, etc.)
//     • Hospital medication charges
// If the patient was an out-patient the following data should be entered:
//     • Charges for hospital services (lab tests, etc.)
//     • Hospital medication charges
// The program should use two overloaded functions to calculate the total charges.
// One of the functions should accept arguments for the in-patient data,
// while the other functions accepts arguments for out-patient data. Both functions
// should return the total charges.
// Input validation: Do not accept negative numbers for any information.

#include<iostream>
#include<iomanip>
#include<cmath>

using namespace std;

// Function Prototypes

double Costs(int numDays, double ratePerday, double lab, double medication);     
double Costs(double lab, double medication);

int main()
{
       int stay;
       double totalIn;
       double totalOut;
       int numDays;
       double ratePerday, lab, medication;
      
       // Get choice of inpatient or outpatient hospital stay
       cout << "You will need to enter a 0 for inpatient stay or a 1 for outpatient stay." << endl;
       cin >> stay;

       // Validate the choice
       while (stay != 0 && stay != 1)
       {
              cout << "Please enter 0 for inpatient stay or a 1 for outpatient stay." << endl;
              cin >> stay;
       }
      
       // Process selection
       switch(stay)
       {
       // Inpatient Stay
       case 0:      
              cout << "Please enter the number of days spent at the hospital: " << endl;
              cin >> numDays;
              cout << "Please enter the hospital's daily rate: " << endl;
              cin >> ratePerday;
      
              cout << "Please enter the charges for labwork: " << endl;
              cin >> lab;
              cout << "Please enter the charges for medications: " << endl;
              cin >> medication;
              totalIn = Costs(numDays, ratePerday, lab, medication);
              cout << "The total inpatient costs are: $" << totalIn << endl;
              break;

       // Outpatient Stay
       case 1:
              cout << "Please enter the charges for labwork: " << endl;
              cin >> lab;
              cout << "Please enter the charges for medications: " << endl;
              cin >> medication;
              totalOut = Costs(lab, medication);
              cout << "The total outpatient costs are: $" << totalOut << endl;
              break;
       }

       system("Pause");
       return 0;
}

// function for Inpatient Stay
double Costs(int numDays, double ratePerday, double lab, double medication)
{
       // Calculate total inpatient costs
       return (numDays * ratePerday) + lab + medication;
}

// function for Outpatient Stay
double Costs(double lab, double medication)
{
       // Calculate total inpatient costs
       return lab + medication;
}


Wednesday, March 9, 2011

Cybercrime Prevention Tips

Internet Crime Prevention Tips

 Internet crime schemes that steal millions of dollars each year from victims continue
to plague the Internet through various methods. Following are preventative measures
that will assist you in being informed prior to entering into transactions over
the Internet:

    *  Auction Fraud
    *  Counterfeit Cashier's Check
    *  Credit Card Fraud
    *  Debt Elimination
    *  DHL/UPS
    *  Employment/Business Opportunities
    *  Escrow Services Fraud
    *  Identity Theft
    *  Internet Extortion
    *  Investment Fraud
    *  Lotteries
    *  Nigerian Letter or "419"
    *  Phishing/Spoofing
    *  Ponzi/Pyramid
    *  Reshipping
    *  Spam
    *  Third Party Receiver of Funds
      
 Auction Fraud
        *  Before you bid, contact the seller with any questions you have.
        *  Review the seller's feedback.
        *  Be cautious when dealing with individuals outside of your own country.
        *  Ensure you understand refund, return, and warranty policies.
        *  Determine the shipping charges before you buy.
        *  Be wary if the seller only accepts wire transfers or cash.
        *  If an escrow service is used, ensure it is legitimate.
        *  Consider insuring your item.
        *  Be cautious of unsolicited offers.
 
Counterfeit Cashier's Check
        *  Inspect the cashier's check.
        *  Ensure the amount of the check matches in figures and words.
        *  Check to see that the account number is not shiny in appearance.
        *  Be watchful that the drawer's signature is not traced.
        *  Official checks are generally perforated on at least one side.
        *  Inspect the check for additions, deletions, or other alterations.
        *  Contact the financial institution on which the check was drawn to ensure legitimacy.
        *  Obtain the bank's telephone number from a reliable source, not from the check itself.
        *  Be cautious when dealing with individuals outside of your own country.
  
Credit Card Fraud
        *  Ensure a site is secure and reputable before providing your credit card number online.
        *  Don't trust a site just because it claims to be secure.
        *  If purchasing merchandise, ensure it is from a reputable source.
        *  Promptly reconcile credit card statements to avoid unauthorized charges.
        *  Do your research to ensure legitimacy of the individual or company.
        *  Beware of providing credit card information when requested through unsolicited emails.
          
Debt Elimination
        *  Know who you are doing business with — do your research.
        *  Obtain the name, address, and telephone number of the individual or company.
        *  Research the individual or company to ensure they are authentic.
        *  Contact the Better Business Bureau to determine the legitimacy of the company.
        *  Be cautious when dealing with individuals outside of your own country.
        *  Ensure you understand all terms and conditions of any agreement.
        *  Be wary of businesses that operate from P.O. boxes or maildrops.
        *  Ask for names of other customers of the individual or company and contact them.
        *  If it sounds too good to be true, it probably is.
          
DHL/UPS
        *  Beware of individuals using the DHL or UPS logo in any email communication.
        *  Be suspicious when payment is requested by money transfer before the goods will
          be delivered.
        *  Remember that DHL and UPS do not generally get involved in directly collecting payment
          from customers.
        *  Fees associated with DHL or UPS transactions are only for shipping costs and never
          for other costs associated with online transactions.
        *  Contact DHL or UPS to confirm the authenticity of email communications received.
              
Employment/Business Opportunities
        *  Be wary of inflated claims of product effectiveness.
        *  Be cautious of exaggerated claims of possible earnings or profits.
        *  Beware when money is required up front for instructions or products.
        *  Be leery when the job posting claims "no experience necessary".
        *  Do not give your social security number when first interacting with your prospective
          employer.
        *  Be cautious when dealing with individuals outside of your own country.
        *  Be wary when replying to unsolicited emails for work-at-home employment.
        *  Research the company to ensure they are authentic.
        *  Contact the Better Business Bureau to determine the legitimacy of the company.
                
Escrow Services Fraud
        *  Always type in the website address yourself rather than clicking on a link provided.
        *  A legitimate website will be unique and will not duplicate the work of other companies.
        *  Be cautious when a site requests payment to an "agent", instead of a corporate entity.
        *  Be leery of escrow sites that only accept wire transfers or e-currency.
        *  Be watchful of spelling errors, grammar problems, or inconsistent information.
        *  Beware of sites that have escrow fees that are unreasonably low.
   
Identity Theft
        *  Ensure websites are secure prior to submitting your credit card number.
        *  Do your homework to ensure the business or website is legitimate.
        *  Attempt to obtain a physical address, rather than a P.O. box or maildrop.
        *  Never throw away credit card or bank statements in usable form.
        *  Be aware of missed bills which could indicate your account has been taken over.
        *  Be cautious of scams requiring you to provide your personal information.
        *  Never give your credit card number over the phone unless you make the call.
        *  Monitor your credit statements monthly for any fraudulent activity.
        *  Report unauthorized transactions to your bank or credit card company as soon as
          possible.
        *  Review a copy of your credit report at least once a year.

Internet Extortion
        *  Security needs to be multi-layered so that numerous obstacles will be in the way
          of the intruder.
        *  Ensure security is installed at every possible entry point.
        *  Identify all machines connected to the Internet and assess the defense that's engaged.
        *  Identify whether your servers are utilizing any ports that have been known to represent
          insecurities.
        *  Ensure you are utilizing the most up-to-date patches for your software.
        
Investment Fraud
         *  If the "opportunity" appears too good to be true, it probably is.
        *  Beware of promises to make fast profits.
        *  Do not invest in anything unless you understand the deal.
        *  Don't assume a company is legitimate based on "appearance" of the website.
        *  Be leery when responding to invesment offers received through unsolicited email.
        *  Be wary of investments that offer high returns at little or no risk.
        *  Independently verify the terms of any investment that you intend to make.
        *  Research the parties involved and the nature of the investment.
        *  Be cautious when dealing with individuals outside of your own country.
        *  Contact the Better Business Bureau to determine the legitimacy of the company.
      
Lotteries
        *  If the lottery winnings appear too good to be true, they probably are.
        *  Be cautious when dealing with individuals outside of your own country.
        *  Be leery if you do not remember entering a lottery or contest.
        *  Be cautious if you receive a telephone call stating you are the winner in a lottery.
        *  Beware of lotteries that charge a fee prior to delivery of your prize.
        *  Be wary of demands to send additional money to be eligible for future winnings.
        *  It is a violation of federal law to play a foreign lottery via mail or phone.
  
Nigerian Letter or "419"
        *  If the "opportunity" appears too good to be true, it probably is.
        *  Do not reply to emails asking for personal banking information.
        *  Be wary of individuals representing themselves as foreign government officials.
        *  Be cautious when dealing with individuals outside of your own country.
        *  Beware when asked to assist in placing large sums of money in overseas bank accounts.
        *  Do not believe the promise of large sums of money for your cooperation.
        *  Guard your account information carefully.
        *  Be cautious when additional fees are requested to further the transaction.
          
Phishing/Spoofing
        *  Be suspicious of any unsolicited email requesting personal information.
        *  Avoid filling out forms in email messages that ask for personal information.
        *  Always compare the link in the email to the link that you are actually directed
          to.
        *  Log on to the official website, instead of "linking" to it from an unsolicited email.
        *  Contact the actual business that supposedly sent the email to verify if the email
          is genuine.
          
Ponzi/Pyramid
        *  If the "opportunity" appears too good to be true, it probably is.
        *  Beware of promises to make fast profits.
        *  Exercise diligence in selecting investments.
        *  Be vigilant in researching with whom you choose to invest.
        *  Make sure you fully understand the investment prior to investing.
        *  Be wary when you are required to bring in subsequent investors.
        *  Independently verify the legitimacy of any investment.
        *  Beware of references given by the promoter.
    
Reshipping
        *  Be cautious if you are asked to ship packages to an "overseas home office."
        *  Be cautious when dealing with individuals outside of your own country.
        *  Be leery if the individual states that his country will not allow direct business
          shipments from the United States.
        *  Be wary if the "ship to" address is yours but the name on the package is not.
        *  Never provide your personal information to strangers in a chatroom.
        *  Don't accept packages that you didn't order.
        *  If you receive packages that you didn't order, either refuse them upon delivery
          or contact the company where the package is from.
         
Spam
        *  Don't open spam. Delete it unread.
        *  Never respond to spam as this will confirm to the sender that it is a "live" email
          address.
        *  Have a primary and secondary email address - one for people you know and one for
          all other purposes.
        *  Avoid giving out your email address unless you know how it will be used.
        *  Never purchase anything advertised through an unsolicited email.
     
Third Party Receiver of Funds
        *  Do not agree to accept and wire payments for auctions that you did not post.
        *  Be leery if the individual states that his country makes receiving these type of
          funds difficult.
        *  Be cautious when the job posting claims "no experience necessary".
        *  Be cautious when dealing with individuals outside of your own country.
          
Source: http://www.ic3.gov/crimeschemes.aspx