Sabtu, 13 Oktober 2012

Rumus luas segitiga menggunakan coding Algoritma

Edit Posted by with No comments
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication2;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class JavaApplication2 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner masukan=new Scanner(System.in);
        int Alas;
        int Tinggi;
      
      
      
        System.out.print("Nilai Alas->");
        Alas=masukan.nextInt();
        System.out.print("Nilai Tinggi->");
        Tinggi=masukan.nextInt();
        int Luas=Alas*Tinggi/2;
      
        System.out.println("Alas ="+ Alas);
        System.out.println("Tinggi   ="+ Tinggi);
        System.out.println("Luas    ="+ Luas);
      
    }
}

Kamis, 11 Oktober 2012

coding C# untuk menentukan bilangan ganjil negatif, ganjil positif

Edit Posted by with 1 comment

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int angka;

            Console.Write("Masukkan angka = ");
            angka = int.Parse(Console.ReadLine());
            if (angka % 2 == 1)
            {
                Console.WriteLine("Bilangan ganjil positif");
            }
            else if (angka % 2 == 0)
            {
                Console.WriteLine("Bilangan genap positif");
            }
            else if (angka % 2 == -1)
            {
                Console.WriteLine("Bilangan ganjil negatif");
            }
            else if (angka % 2 == -0)
            {
                Console.WriteLine("Bilangan genap negatif");
            }
            else
            {
                Console.WriteLine("Angka yang diinputkan " + "tidak valid");
            }
            Console.Read();



dan hasilnya tadaaa!