4 Examples in C# (sharp) in application console + Codes

By kedinn 2013/02/17

1) A man wishes to know whichever money is generated by concept of interests on
amount that he has in investment in the bank. He will decide to always reinvert the interests
and when these exceed to S/.7000, and in that case he wishes to know whichever money will have
finally in its account.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ejercicio01 \ {
    class Man
    \ {
        name deprives string to you;
        money prevails to you float;
        public void Home ()
        \ {
            Console.WriteLine (“---------BANK FOROSHTML5.ORG--------?);
            Console.WriteLine (“-----------------------------?);
            Console.WriteLine (“ENTERS ITS NAME: ?);
            name = Console.ReadLine ();
            Console.WriteLine (“ENTERS ITS AMOUNT MONEY; ?);
            money = float. Parse (Console.ReadLine ());
            Console.Clear ();

        }
        public void Imprimir ()
        \ {
            Console.WriteLine (“---------BANK FOROSHTML5.ORG--------?);
            Console.WriteLine (“-----------------------------?);

            Console.WriteLine (“NAME:    “+ name);

            if (money > 7000)
            \ {
                Console.WriteLine (“YOU CANNOT EXCEED the AMOUNT DE S/7000?);
            }
            else
            \ {
                Console.WriteLine (“INVESTMENT: ? + money);
            }
            Console.ReadLine ();

        }
        static void Main (string [] args) 
        \ {

            Man Rep = new Man ();
            Rep. Home ();
            Rep. To print ();

        }
    }}

 

2) In a warehouse a 20% become of discount to the clients whose purchase surpasses
S/.1000 What will be the amount that a person by her purchase paid?

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ejercicios02 \ {
    class Client
    \ {
        float prevails to you discount;
        price prevails to you float;
        public void Home ()
        \ {
            Console.WriteLine (“ENTERS PRICE: ?);
            price = float. Parse (Console.ReadLine ());
            Console.Clear ();

        }
        public void Discount ()
        \ {
            if (price > 1000)
            \ {
                float head of cattle = (price * 20)/100;
                discount = price - head of cattle;
                Console.WriteLine (“--------KEDINN LIES DOWN -------?);
                Console.WriteLine (“DISCOUNT OF 20% TO SURPASS S/1000?);
                Console.WriteLine (“PRICE IS: ? + discount);
                Console.ReadLine ();
            }
            else 
            \ {
                Console.WriteLine (“--------KEDINN LIES DOWN -------?);

                Console.WriteLine (“PRICE IS: ? + price);
                Console.ReadLine ();

            }
            Console.ReadKey ();

        }
        static void Main (string [] args)
        \ {
            Console.WriteLine (“--------KEDINN LIES DOWN -------?);
            Client clie = new Client ();
            clie. Home ();
            clie. Discount ();

        }

    }}

 

3) A worker needs to calculate his weekly wage, which is obtained from the following one.
way:
- If it works 40 hours or less S/.16 per hour is pleased to him
- If it works but of 40 hours S/.16 by each one of the first 40 is pleased to him
hours and S/.20 by hourly extra.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ejercicio3 \ {
    class Shirts
    \ {
        int shirts;
        float price;
        public void Ingresar () 
        \ {
            Console.WriteLine (“IT ENTERS I NUMBER OF SHIRTS?);
            shirts = int. Parse (Console.ReadLine ());
            Console.WriteLine (“PRICE OF the SHIRTS ENTERS?);
            price = float. Parse (Console.ReadLine ());
        }
        public void Work ()
        \ {
            if (shirts >= 3)
            \ {
                float a = (price * 20)/100;
                float b = price - a;
                Console.WriteLine (“DISCOUNT 20% PRICE IS:  “+ b);

            }
            else 
            \ {
                float a = (price * 01)/100;
                float b = price - a;
                Console.WriteLine (“DISCOUNT 20% PRICE IS:  ? + b);
            }
            Console.ReadKey ();
        }
        static void Main (string [] args)
        \ {
            Shirts sem = new Shirts ();
            sem. To enter ();
            sem. Work ();

        }
    }}

 

4) To make an algorithm that calculates the total to pay by the purchase of shirts. If they are bought
three shirts or but are applied a discount of 20% on the total of the purchase and if they are
less than three shirts a discount of 10%

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ejercicio3 \ {
    class Shirts
    \ {

        float price;
        public void Ingresar () 
        \ {
            Console.WriteLine (“-----COMPANY FAEMAS-----?);

            Console.WriteLine (“PRICE OF the SHIRTS ENTERS?);
            price = float. Parse (Console.ReadLine ());
        }
        public void Work ()
        \ {
            Console.WriteLine (“-----COMPANY FAEMAS-----?);
            if (price >= 500000)
            \ {

                Console.WriteLine (“the company will have the capacity to invest of its own money a 55% of the amount of the purchase, to borrow to the bank a 30% and the rest would pay it asking for a credit to the manufacturer?);

            }
            else 
            \ {

                Console.WriteLine (“the company will have capacity to invest of its own money a 70% and rest 30% will pay it asking for credit to the manufacturer.  ?);
            }
            Console.ReadKey ();
        }
        static void Main (string [] args)
        \ {
            Shirts sem = new Shirts ();

            sem. To enter ();
            sem. Work ();

        }
    }}