Circuit Negma

C++, C, VB.NET, PCB, Electronics, Circuit Design

Archive for February, 2006

converter — Bug with the Check function

Posted by Circuit Negma on February 24, 2006


// ************************************************************************
// * Created By: Circuit Negma                                            *
// * Date      : Jan 1 , 2006                                             *
// * File Name : converter                                                *
// * Description :                                                        *
// * THIS IS a general metric converter                                   *
// ************************************************************************

// SEC. 1: PRE-PROCESSOR DIRECTIVES
// Library – is a collection of functions and symbols that are needed to run
//           C++ program.
// Library – has a name and is referred to by a header file.

#include <iostream>   // Input/Output functions are contained in the header
                        // file iostream.h
                        // The header file contain the needed instructions and
                        // descriptions of the functions needed to perform input
                        // output operations.
#include <cstdlib>

using namespace std;

float check()
{
 int n;
 bool flag = true;
 bool flagy;
 
 cin.clear();
 flag = cin >> n;
 
 while (!flag)
 {
       cout << endl;
       cout << “this is not a number” << endl;
       cout << ” you entered :  ” << n << endl;
       cout << “please enter a number again: “;
       cin.clear();
       cin.ignore();
}
       cout << “this is n:  ” << n << endl << endl;
      
/* while(flag)
 {
         cin.clear();
         flagy = cin >> i;
        
         if (flagy == 1 )
         {
             cout << “this is a number” << endl;
             cout << flagy << endl;
             flag = false;
             //return (float) i;   
         }
         else
         {
             cout << “this is not a number” << endl;
             cout << flagy << endl;
         }
 }*/
 
  return (float) n;

}

void cmConv (float n)
{
     float iin, ift;
    
     cout << endl << endl;
     cout << ” cmConv has been chosen” << endl;
     iin = n * 0.394;
     ift = n * 0.0328;
     cout << iin << ” in” << endl;
     cout << ift << ” ft” << endl;
}

void inchConv (float n)
{
      float incm, inft;
    
     cout << endl << endl;
     cout << ” inchConv has been chosen” << endl;
     incm = n / 0.394;
     inft = (n * 0.0328) / 0.394;
     cout << incm << ” cm” << endl;
     cout << inft << ” ft” << endl;

}

void ftConv (float n)
{
     float ftcm, ftin;
    
     cout << endl << endl;
     cout << ” ftConv has been chosen” << endl;
     ftcm = n / 0.0328;
     ftin = (n * 0.394) / 0.0328;
     cout << ftcm << ” cm” << endl;
     cout << ftin << ” in” << endl;
}

int main()
{
    cout.flush();
   
    int i;
    float icm, iin, ift;
    string flag;
   
    cout << ” _____________________________” << endl << endl;
    cout << ” – Created By: Circuit Negma -” << endl;
    cout << ” – File Name : Converter.cpp -” << endl;
    cout << ” – Date      : Jan 17, 2006  -” << endl;
    cout << ” _____________________________” << endl;
    cout << endl << endl;
main_face:   
    cout << ” _________________________________”  << endl;
    cout << “|                                 |” << endl;
    cout << “| Welcome to C++                  |” << endl;
    cout << “|                                 |” << endl;
    cout << “| Metric Calculator Menu          |” << endl;
    cout << “|___________________________      |” << endl;
    cout << “|                                 |” << endl;
    cout << “| 1. Convert from ‘cm’ to …     |” << endl;
    cout << “| 2. Convert from ‘inch’ to …   |” << endl;
    cout << “| 3. Convert from ‘ft’ to …     |” << endl;
    cout << “| 4. Exit Sat. Link System.       |” << endl;
    cout << endl;
    cout << ” Please, Chose from the Menu: “;
    cin  >> i;
    cout << endl;
   
    if ( i == 1 )
    {
         cout << “You chosed to convert from ‘cm’ to … ” << endl;
         cout << “Please, Enter the amount in ‘cm’:  “;
         icm = check();
         cout << icm;
         cmConv(icm);
         cout << endl << endl;
         goto main_face;
    }
    else if (i == 2)
    {
         cout << “You chosed to convert from ‘inch’ to … ” << endl;
         cout << “Please, Enter the amount in ‘inch’:  “;
         cin >> iin;
         inchConv (iin);
         cout << endl << endl;
         goto main_face;
    }
    else if (i == 3)
    {
         cout << “You chosed to convert from ‘ft’ to … ” << endl;
         cout << “Please, Enter the amount in ‘ft’:  “;
         cin >> ift;
         ftConv (ift);
         cout << endl << endl;
         goto main_face;
    }
    else if (i == 4)
    {
             cout << “Exit Sat. Link System.”;
            
    }
    else
    {
        cout << “exit”;
    }
   
    //cin >> i;
    return 0;
}

 

Posted in C++ | Leave a Comment »

Exam2.jpg

Posted by Circuit Negma on February 16, 2006


Posted in AutoCad 2006 | Leave a Comment »

Exercise2.jpg

Posted by Circuit Negma on February 16, 2006


Posted in AutoCad 2006 | Leave a Comment »

Drawing1

Posted by Circuit Negma on February 16, 2006


Posted in AutoCad 2006 | Leave a Comment »

Exam1.jpg

Posted by Circuit Negma on February 16, 2006


Posted in AutoCad 2006 | Leave a Comment »

Exercise1.jpg

Posted by Circuit Negma on February 16, 2006


Posted in AutoCad 2006 | Leave a Comment »

Shape Changer and shifter

Posted by Circuit Negma on February 11, 2006


Exam.java
===========

import java.util.*;
import java.awt.*;

public class Exam {

private Point upperCorner;

public Exam (Point aPoint){

 this.upperCorner = new Point(aPoint);
  }
 
 public void circle (Graphics g) {
   
   g.drawOval(this.upperCorner.x,this.upperCorner.y,10,10);
  }
 public void square(Graphics g) {
 
   g.drawRect(this.upperCorner.x,this.upperCorner.y,10,10);
 }
 
 }

________________________________________________

Shapes.java
==============
/*
 Trivial applet that displays a string – 4/96 PNL
 Updated stationery – 8/2000 C.Phan
*/

import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;

public class Shaps extends Applet implements ActionListener
{

 Exam aExam;
 private int a,b;
 private Button Circle,Square,Reset;
 private static final String CIRCLE = “Circle”;
 private static final String SQUARE = “Square”;
 private static final String RESET = “Reset”;
 private boolean cir,squa;
 
 public void init() {
  
  this.cir = true;
  this.a = 0;
  this.b = 50;
  this.aExam = new Exam(new Point(a,b));
  
  this.Circle = new Button(CIRCLE);
  this.Circle.addActionListener(this);
  this.Square = new Button(SQUARE);
  this.Square.addActionListener(this);
  this.Reset = new Button(RESET);
  this.Reset.addActionListener(this);
  
  Panel main = new Panel(new GridLayout(1,3));
  main.add(Circle);
  main.add(Square);
  main.add(Reset);
  add(main);
  
  repaint();
 }
 
 public void paint( Graphics g ) {
  if (cir){
  aExam.circle(g);}
  else
  aExam.square(g);
 }
 
 public void actionPerformed(ActionEvent event){
  String s = event.getActionCommand();
  
  if (s.equals(CIRCLE)){
   this.a = a+10;
   this.b = 50;
   this.aExam = new Exam(new Point(a,b));
   this.cir = true;
   this.squa = false;
   }
  else if (s.equals(SQUARE)){
   this.a = a+10;
   this.b = 50;
   this.aExam = new Exam(new Point(a,b));
   this.cir = false;
   this.squa = true;}
  else if (s.equals(RESET)){
   this.a = 0;
   this.b = 50;
   this.aExam = new Exam(new Point(a,b));
   this.cir = true;
   this.squa = false;}
  
   repaint();

}

}

_______________________________________________

 

Posted in Java | Leave a Comment »