Search Blog

Biyernes, Enero 18, 2013

Write a program that demonstrates the difference between predecrementing and postdecrementing using the decrement operator --.

Java Codes
--+o0O0o+--

Write a program that demonstrates the difference between predecrementing and postdecrementing using the decrement operator --. 


Code:



import java.util.Scanner;

public class MachineProblem12 {

    public static void main(String[] args) {
       
        Scanner input_user = new Scanner(System.in);
       
        int base_num,loop_num,base_num1,x,y;
       
        System.out.println("*****************************************");
       
            System.out.print("  Enter base number: ");
            base_num = input_user.nextInt();
           
            base_num1 = base_num;
           
            System.out.print("  Enter number of loop: ");
            loop_num = input_user.nextInt();
           
            x = 0;
            y = 0;
           
            for(int z = 0;z < loop_num;z++)
            {
                if(z == 0)
                {  
                    x = --base_num;
                    y = base_num1--;
                    System.out.println("");
System.out.println(" xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
System.out.println(" ||# of LOOP||Predecrement||Postdecrement  ||");
System.out.println(" xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
System.out.println(" ||   1st   ||     " + x + "         " + y );
                    System.out.println(" xxxxxxxxxxxxxxx");
                }
                if(z == 1)
                {  
                    x = --base_num;
                    y = base_num1--; 
System.out.println(" ||   2nd   ||     " + x + "         " + y);
                    System.out.println(" xxxxxxxxxxxxxxx");
                }
              


 if(z == 2)
                {  
                    x = --base_num;
                    y = base_num1--;
System.out.println(" ||    3rd    ||      " + x + "      " + y);
                    System.out.println(" xxxxxxxxxxxxxxx");
                }
                if(z > 2)
                {  
                    x = --base_num;
                    y = base_num1--;
System.out.println(" || " + (z + 1) +"th|| " + x + "    " + y);
                    System.out.println(" xxxxxxxxxxxxxxx");
                }
            }
    }
}

Develop a program that will determine the gross pay for each of several employees. The company pays “straight-time” for the first 40 hours worked by each employee and pays “time-and-a-half” for all hours worked in excess of 40 hours. You are given a list of the employees of the company, the number of hours each employee worked last week and the hourly rate of each employee. Your program should input this information for each employee, and should determine and display the employee’s gross pay.


Java Codes
--+o0O0o+--

Develop a program that will determine the gross pay for each of several employees. The company pays “straight-time” for the first 40 hours worked by each employee and pays “time-and-a-half” for all hours worked in excess of 40 hours. You are given a list of the employees of the company, the number of hours each employee worked last week and the hourly rate of each employee. Your program should input this information for each employee, and should determine and display the employee’s gross pay.


Code:


import java.util.Scanner;

public class MachineProblem11 {

    public static void main(String[] args) {

        Scanner input_user = new Scanner(System.in);
       
        float hour_rate,salary;
        int hours_worked;
       
        System.out.println("*****************************************");
        for(int x = 0;x < 1000;x++)
        { 
           
     System.out.print("  Enter # of hours worked (-1 to end): ");
            hours_worked = input_user.nextInt();
           
            if(hours_worked != -1)
            {
System.out.print("  Enter hourly rate of the worker ($00.00): ");
                hour_rate = input_user.nextFloat();
               
                salary = hours_worked * hour_rate;
                System.out.println("*****************************************");
  System.out.println("  The interest charge is $" + salary);
                System.out.println("*****************************************");
            }
            else
            {
                return;
            }        
            
        }
    }
}

The simple interest on a loan is calculated by the formula. interest = principal * rate * days / 365; The preceding formula assumes that rate is the annual interest rate, and therefore includes the division by 365 (days). Develop a program that will input principal, rate and days for several loans, and will calculate and display the simple interest for each loan, using the preceding formula.


Java Codes
--+o0O0o+--

The simple interest on a loan is calculated by the formula.

interest = principal * rate * days / 365;

The preceding formula assumes that rate is the annual interest rate, and therefore includes the division by 365 (days). Develop a program that will input principal, rate and days for several loans, and will calculate and display the simple interest for each loan, using the preceding formula.


Code:


import java.util.Scanner;

public class MachineProblem10 {

    public static void main(String[] args) {
       
        Scanner input_user = new Scanner(System.in);
       
        float principal,rate,interest;
        int loan_days;
       
        System.out.println("*****************************************");
        for(int x = 0;x < 1000;x++)
        { 
           
        System.out.print("  Enter loan principal (-1 to end): ");
            principal = input_user.nextFloat();
           
            if(principal != -1)
            {
                System.out.print("  Enter interest rate: ");
                rate = input_user.nextFloat();
               
          System.out.print("  Enter term of the loan in days: ");
                loan_days = input_user.nextInt();
               
                interest = principal * rate * loan_days / 365;
                System.out.println("*****************************************");
System.out.println("  The interest charge is $" + interest);               System.out.println("*****************************************");
            }
            else
            {
                return;
            }        
            
        }
    }
}

One large chemical company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who sells $5000 worth of chemicals in a week receives $200 plus 9% of $5000, or a total of $650. Develop a program that will input each salesperson’s gross sales for last week and will calculate and display that salesperson’s earnings. Process one salesperson’s figures at a time.


Java Codes
--+o0O0o+--

One large chemical company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who sells $5000 worth of chemicals in a week receives $200 plus 9% of $5000, or a total of $650. Develop a program that will input each salesperson’s gross sales for last week and will calculate and display that salesperson’s earnings. Process one salesperson’s figures at a time.


Code:


import java.util.Scanner;

public class MachineProblem9 {

    public static void main(String[] args) {
       
        Scanner input_user = new Scanner(System.in);
       
        float salary_$;
        double recieve_this_week;
       
        System.out.println("******************************************");
        for(int x = 0;x < 1000;x++)
        { 
           
     System.out.print("  Enter sales in dollars (-1 to end): ");
            salary_$ = input_user.nextFloat();
           
            if(salary_$ != -1)
            {
                recieve_this_week = 0.09 * salary_$ + 200;
     System.out.println("  Salary is : $" + recieve_this_week);
                System.out.println("*****************************************");
            }
            else
            {
                return;
            }  
               
            
        }
    }
}

Develop a program that will determine if a department store customer has exceeded the credit limit on a charge account. For each customer, the following facts are available: 1. Account number 2. Balance at the beginning of the month 3. Total of all items charged by this customer this month 4. Total of all credits applied to this customer’s account this month 5. Allowed credit limit The program should input each of these facts, calculate the new balance (= beginning balance + charges – credits), and determine if the new balance exceeds the customer’s credit limit. For those customers whose credit limit is exceeded, the program should display the customer’s account number, credit limit, new balance, and the message “Credit limit exceeded.”


Java Codes
--+o0O0o+--


Develop a program that will determine if a department store customer has exceeded the credit limit on a charge account. For each customer, the following facts are available:
1.Account number
2.Balance at the beginning of the month
3.Total of all items charged by this customer this month
4.Total of all credits applied to this customer’s account this month
5.Allowed credit limit

The program should input each of these facts, calculate the new balance (= beginning balance + charges – credits), and determine if the new balance exceeds the customer’s credit limit. For those customers whose credit limit is exceeded, the program should display the customer’s account number, credit limit, new balance, and the message “Credit limit exceeded.”


Code:

import java.util.Scanner;

public class MachineProblem8 {

    public static void main(String[] args) {
       
         Scanner input_user = new Scanner(System.in);
       
        int  account_number;
        float beginning_balance,total_charges;
        float total_credits,credit_limit,new_bal;
       
        System.out.println("*****************************************");
        for(int x = 0;x < 1000;x++)
        { 
           
         System.out.print(" Enter account number (-1 to end): ");
            account_number = input_user.nextInt();
           
            if(account_number != -1)
            {
                System.out.print(" Enter beginning balance: ");
                beginning_balance = input_user.nextFloat();
               
                System.out.print(" Enter total charges: ");
                total_charges = input_user.nextFloat();
               
                System.out.print(" Enter total credits: ");
                total_credits = input_user.nextFloat();
               
                System.out.print(" Enter credit limit: ");
                credit_limit = input_user.nextFloat();


new_bal = beginning_balance + total_charges - total_credits;
                    if(new_bal > credit_limit)
                    {
                        System.out.println("*****************************************");

       System.out.println("     Account: " + account_number);
       System.out.println("     Credit Limit: " + credit_limit);
       System.out.println("     Balance: " + beginning_balance);
                        System.out.println("******************************************");
                        System.out.println("=========================================");
       System.out.println("||     CREDIT LIMIT EXCEEDED    ||");
System.out.println("=========================================");
                    }
               
System.out.println("*****************************************");
            }
            else
            {
                return;
            }  
               
            
        }
    }
}

Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several tankfuls of gasoline by recording miles driven and gallons used for each tankful. Develop a program that will input the miles driven and gallons used for each tankful. The program should calculate and display the miles per gallon obtained for each tankful. After processing all input information, the program should calculate and print the combined miles per gallon obtained for all tankfuls.


Java Codes

--+o0O0o+--

Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several tankfuls of gasoline by recording miles driven and gallons used for each tankful. Develop a program that will input the miles driven and gallons used for each tankful. The program should calculate and display the miles per gallon obtained for each tankful. After processing all input information, the program should calculate and print the combined miles per gallon obtained for all tankfuls.


Code:


import java.util.Scanner;

public class MachineProblem7 {

    public static void main(String[] args) {
       
        Scanner input_user = new Scanner(System.in);
       
        float gallons,miles;
        float computed,overall = 0,result = 0,p = 0;
       
        System.out.println("*****************************************");
    
 for(int x = 0;x < 1000;x++)
      { 
           
       System.out.print(" Enter the galloon used (-1 to end): ");
            gallons = input_user.nextFloat();
           
            if(gallons != -1)
            {
                System.out.print(" Enter the miles driven: ");
                miles = input_user.nextFloat();
               
                computed = miles / gallons;
                overall = overall + computed;

System.out.println("The miles / gallon for this tank was " + computed);
                p++;
                System.out.println("*****************************************");
            }
            if(gallons == -1)
            {
                result = overall / p;
                System.out.println("*****************************************");

System.out.println("   The overall average miles / gallon was " + result);
                System.out.println("*****************************************");
                return;
            }        
            
        }
    }
}

Write a program that reads in the radius of a circle and the compute and display the diameter, circumference and area. Use the constant value 3.14159 for ( pi ) π .

Java Codes
--+o0O0o+--

Write a program that reads in the radius of a circle and the compute and display the diameter, circumference and area. Use the constant value 3.14159 for ( pi ) π


Code:


import java.util.Scanner;

public class MachineProblem4 {

    public static void main(String[] args) {
       
        Scanner input_user = new Scanner(System.in);
       
        int radius,diameter;
        double PI,circum,area;
       
        System.out.print("Enter radius: ");
        radius = input_user.nextInt();
       
        PI = 3.14159;
        diameter = radius * 2;
        circum = PI * diameter;
        area = PI * (radius * radius);
       
        System.out.println("******************************************");

        System.out.println(" Diameter --------> " + diameter );

System.out.println("******************************************");

        System.out.println(" Circumference ---> " + circum);

System.out.println("******************************************");

        System.out.println(" Area ------------> " + area);
        System.out.println("******************************************");
       
    }
}

Write a program that asks the user to enter 5 numbers and display the numbers in descending order.


Java Codes

--+o0O0o+--


Write a program that asks the user to enter 5 numbers and display the numbers in descending order.

Code:

import java.util.Scanner;

public class MachineProblem2 {

    public static void main(String[] args) {
   
    Scanner input_user = new Scanner(System.in);
   
    int[] num = new int[5];
    int temp;
       
        System.out.println("******************************************");
      
        System.out.println("   Enter Five(5) Numbers");

System.out.println("*****************************************");
        
        for(int x = 0; x < 5;x++)
        {
            System.out.print(" Number" + (x+1) + " :");
            num[x] = input_user.nextInt();
           
        }
       
        for(int w = 0;w < 4;w++)
        {
            for(int y = 0;y < 4;y++)
            {
                if(num[y] < num[y + 1])
                {
                 temp = num[y];
                 num[y] = num[y + 1];
                 num[y + 1] = temp;
                }
            }
        }
        System.out.println("******************************************");

        System.out.println(" Descending Order of the Numbers");

System.out.println("******************************************");
        
for(int z = 0;z < 5;z++)
        {
            System.out.println(num[z]);
        }
    }
}



To make this code Ascending just change this statement 
if(num[y] < num[y + 1]).Change the < (less than sign) to > (greater than sign).

Write a program that asks the user to enter 2 numbers, and display the SUM, DIFFERENCE, PRODUCT, QUOTIENT and REMAINDER of the 2 numbers.


Java Codes

--+o0O0o+--

Write a program that asks the user to enter 2 numbers, and display the SUM, DIFFERENCE, PRODUCT, QUOTIENT and REMAINDER of the 2 numbers.

Code:


import java.util.Scanner;

public class MachineProblem1 {

    public static void main(String[] args) {

    Scanner input_user = new Scanner(System.in);
       
        float fi,se;
       
        System.out.print("Enter First Number: ");
        fi = input_user.nextFloat();
       
        System.out.print("Enter Second Number: ");
        se = input_user.nextFloat();
       
        System.out.println("******************************************");
        System.out.println("  SUM ---------->(fi + se));
        System.out.println("******************************************");
        System.out.println("  DIFFERENCE --->(fi - se));
     System.out.println("******************************************");
        System.out.println("  PRODUCT ------>(fi * se));
        System.out.println("******************************************");
        System.out.println("  QOUTIENT ----->(fi / se));
     System.out.println("******************************************");
        System.out.println("  REMAINDER ---->(fi % se));
        System.out.println("******************************************");
    }
}

Java Language


The "Java" word means depending from its context either Java Platform or Java Language. Java language is an object oriented language form Oracle with a syntax similar to that of C. The Java language attempts to protect the programmer form common C and C++ gotchas. Its scoping is not as complex as C++, but provides separate name spaces via packages and a range of other protections surrounding class. Java has been positioned as an excellent language for developing network-based applications.It is multi-threaded, and many of its libraries are thread-safe.


To know more about the History of Java just click this Link.

Huwebes, Enero 17, 2013

C/C++ Tutorial


 C++ (pronounced "see plus plus") is a statistically typed,free-form,multi-paradigm, compiled,general-purpose programming language.It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. Originally named C with Classes, the language was renamed C++ in 1983, as pun involving the increment operator.It is one of the most popular programming languages and implemented on wide variety of hardware and operating system platforms. An an efficient compiler to native code, its application domains include system software, application software, device drivers, embedded software, high-performance server and client applications, and entertainment software such as video games.


To learn more about C++ Programming just visit this Programming TUTORIAL link.


How to install Bloodshed Dev C++ ?


How to install Bloodshed Dev C++ ?

Just View this Link.

Hard-core Programmer


How to download Bloodshed Dev-C++ ?

Bloodshed Dev-C++ is full-featured programming environment and compiler for creating software in C++. Include in the Dev-C++ environment are all of the standard features necessary for writing, compiling, debugging, and executing programs written in C.

Strictly for the hard-core C++ programmer, Dev-C++ allows you to compose all of your source code without many of the hand-holding features and expenses include in many of the available programming environments.

How to download Bloodshed Dev-C++ ?

Just watch this YOUTUBE VIDEO LINK.

1st C/C++ PROGRAM


This is how to simply print "Hello World!" in C/C++ compiler.

If you don't have C/C++ compiler I referred to download Bloodshed (Dev - C++) compiler just visit http://www.bloodshed.net/devcpp.html or just click this link Bloodshed.


Code:

#include <stdio.h>
#include <conio.h>

int main(){
    
    printf(" Hello World! "); 
    
    getch();
    return 0;
}

H E L L O W O R L D !

Hello World!
   
The most common greetings used in Programming and my first post in my Blog. Blog created minutes ago before this post. Around 11: 00 am January 17,2013. The purpose of this blog is to help and give information to all my co - FUTURE PROGRAMMER even though I'm not yet expert to this field so, I just want only to share my little knowledge about programming and other stuffs about Computers.


God Bless! and continue Compiling! :)