Posts

Displaying Text in a Dialog Box

Image
In this program, will we be showing you how to use JAVA program to display a text using JAVA GUI (Graphics User Interface) in a dialog box. Typically,dialog boxes are windows in which programs display important messages to the user of the program.  This application uses Java's Class JOptionPane which provides prepackaged dialog boxes that enables programs to display windows containing messages to its user. we will be using the  import  javax.swing. JOptionPane which  is an import declaration and is part of the  Java API .  Programmers use import declarations to identify the predefined classes used in Java Program. The import declaration help the compiler locate the classes you intend to use, this tells the compiler that our program uses class JOptionPane from package javax.swing and this package helps programmers create graphical user interfaces (GUI) for applications. The program below illustrates how to create a text in a dialog box...

Printing Your First Java Program

Image
Every programmer first code or writing starts with words like "Hello World", "Am a Programmer" etc, that's what makes programming so fun and interesting in a way that the programmer would one day be writing millions of lines of codes. But before you start writing thousands and millions of codes we have to start from somewhere and that is why this post is very essential to beginners new to coding.  We will be demonstrating how to write "Welcome to Java programming" in a Java language. Java language is one of the most widely used high level programming languages for developing complex and high end applications that can be run on all platforms. thus; its platform independent.  To get started with Java, I recommend using DrJava which is a lightweight development environment for writing Java programs. It is designed primarily for students, providing an intuitive interface and the ability to interactively evaluate Java code. It also incl...

Printing Your First C++ Program

Image
Welcome to C++ If you are here, it means you have taken a very big step to a very lucrative journey ahead to become one of those with super powers of coding, and what better way to start than with C++ I won't bore you with much talk cause this blog is all about codes and codes, but before you start coding in C++ you require an IDE (Integrated Device Environment) which will assist you in writing and running your C++ programs. I would recommend   Code::Blocks with gnu gcc compiler (Which supports C programming Language too), which is the best compiler to start  with for beginners and which i like using most.  To make use of the IDE, install and open the code blocks,  Write the  C++  code and save the file with . cpp  extension. To save the file, go to File > Save (Shortcut: Ctrl + S). To run the program, go to Build > Build and Run. Now let's go ahead with what brought you here which is  writing your first C++ code. The code below...

Printing Your First C Program

Image
Welcome to C If you are here, it means you have taken a very big step to a very lucrative journey ahead to become one of those with super powers of coding, and what better way to start than with C To get started with C you need an IDE. Install the Code::Blocks with gnu gcc compiler, which is the best compiler to start  with for beginners. Write the  C  code and save the file with . c  extension. To save the file, go to File > Save (Shortcut: Ctrl + S). To run the program, go to Build > Build and Run. Now let's go ahead with what brought you here which is  writing your first C++ code.  The code below illustrates just how to do that. This application displays a line of text in a Command prompt using an IDE   #include <stdio.h>   int main( void )   { printf( "Welcome to C!\n" );   } see also Printing Your First C++ Program

Arithmetic, Smallest and Largest

Image
We will be writing an application that  inputs three integers from the user and displays the sum, average, product, smallest and largest of the numbers using a java application GUI (Graphics User Interface) So the first step of the program will be to import javax.swing.JOptionPane which is part of the java packages and which has the capability of displaying and inputting text in dialog box. usually when inputting digits in java applications, it is entered as strings which can then be converted to corresponding data types like integers and floating point numbers. The program code below illustrates how to do a simple arithmetic, smallest and largest of three numbers. import javax.swing. JOptionPane ; public class Arithmetic {   public static void main( String args [])   {     String firstNumber;     String secondNumber;     String thirdNumber;     String compare;       int number1; ...

Averaging Score

Image
Suppose you have a class of ten students who took a quiz. The grades (integers in the range 0 to 100) for this quiz are made available to you. so this program tutorial shows us how to determine the class average on the quiz. What we need to understand about the class average is that it is equal to the sum of the grades divided by the number of students. so the algorithm below for solving this problem must input each grade, keep track of the total of all grades input, perform the averaging calculation and print the result. First of all we will need to use the pseudo code to list the actions to execute and specify the order in which these actions should execute. Pseudo code is an artificial and informal language that helps you develop algorithms. It’s useful for developing algorithms that will be converted to structured Java programs. They are not executed on computers; rather, they merely help you “think out” a program before attempting to write it in a programming l...

Temperature Conversion Program

Image
This program uses the switch statement to convert one temperature degree to another and also uses the JOptionPane input/output dialog box from the javax.swing. package to display the information. we also have to note that when inputting digits in java applications, it is entered as strings which can then be converted to corresponding data types like integers and floating point numbers. the program below illustrates temperature conversion program. import javax.swing.JOptionPane; public class Temperature{   public static void main(String args[])   {     String from;     String to;     String value;       int number1;     int number2;     double temp;       JOptionPane.showMessageDialog(null, "Temperature Conversion");       from = JOptionPane.showInputDialog("Enter no of unit to convert from: 1.Celcius 2. Farenheit 3. Kelvin");     to = JOpti...