Notes, summaries, assignments, exams, and exercises for Computer science for University

Java Applet Example: Capturing and Displaying Personal Data

Computer science1.61 KB

Java Applet for Managing Personal Information

This Java applet lets users enter a first name, paternal surname, maternal surname, and age, then load those values into the display or clear them individually or all at once.

Source Code

The class MichaelHerrera.Michael extends Applet and implements ActionListener.

Declared Components

  • TextField inputs for name, paternal surname, maternal surname, and age
  • Button controls to load or erase each field, plus "Load All" and "Erase All"
  • Variables nombre, Apellido1, Apellido2, and edad that store the loaded values

Initialization

The init() method creates each TextField and Button, adds them to the applet, and registers the applet as an action listener.

Displaying Data

The paint() method draws the stored values on...

Continue reading "Java Applet Example: Capturing and Displaying Personal Data" »

Calculadora em Delphi: Guia Passo a Passo de Programação

Computer science3.42 KB

Calculadora

Botão para digitar os números

Rx Controls

  • > $1
  • > Tirar o R$
  • > Name: visor

Botão +

Adicional

  • > Ok
  • > Name: soma
  • > Caption: +
  • > Font:

Duplo clique (digitar o comando)

Numero1 := visor.value;
Operacao := 1;

Botão -

Adicional

  • > Ok
  • > Name: subtracao
  • > Caption: -
  • > Font:

Duplo clique (digitar o comando)

Numero1 := visor.value;
Operacao := 2;

Botão *

Adicional

  • > Ok
  • > Name: multiplicacao
  • > Caption: *
  • > Font:

Duplo clique (digitar o comando)

Numero1 := visor.value;
Operacao := 3;

Botão /

Adicional

  • > Ok
  • > Name: divisao
  • > Caption: /
  • > Font:

Duplo clique (digitar o comando)

Numero1 := visor.value;
Operacao := 4;

Botão %

Adicional

  • > Ok
  • > Name: porcentagem
  • > Caption: %
  • > Font:

Duplo clique (digitar o comando)

Numero1...

Continue reading "Calculadora em Delphi: Guia Passo a Passo de Programação" »

C# ASP.NET Web Service CRUD Methods for Student Data with SQL Server

Computer science5.23 KB

C# ASP.NET Web Service Methods for Student Data

[WebMethod]

public DataSet SexsqlTodos()

{

DataSet ds = new DataSet();

DataTable dtReg = new DataTable("Sexo");

Bd clBd = new Bd();

dtReg = clBd.sqlSelect("select * from sexo");

ds.Tables.Add(dtReg);

return ds;

}

[WebMethod]

public Boolean sqlLeerExiste(string Codigo)

{

Bd bd = new Bd();

String stSql = String.Format("select * from Alumno where codigo = '{0}'", Codigo);

DataTable dt = bd.sqlSelect(stSql);

if (dt.Rows.Count == 0)

{

return false;

}

return true;

}

[WebMethod]

public Boolean sqlLeerSP(string Codigo)

{

Bd bd = new Bd();

SqlCommand cmd = new SqlCommand();

cmd.CommandText = "Alumno_select";

cmd.CommandType = CommandType.StoredProcedure;

...

Continue reading "C# ASP.NET Web Service CRUD Methods for Student Data with SQL Server" »

Java Sales System: Fixing Code for Personal and Phone Sales

Computer science3.05 KB

Corrected Java Sales Application

The following code has been corrected for syntax, spelling, and structure. Its original logic is preserved.

Base Class: toString and Abstract Method

public String toString() {
    return "Siguiente Numero Disponible: " + siguienteNumeroDisponible +
    "
Numero de transacción: " + numeroTransaccion +
    "
Producto: " + product +
    "
Precio: " + price;
}

Abstract method:

private double calcularComision() {
    return calcularComision();
}


Commission Calculation

public double calcularComision() {
    super.precio * obtenerPrecioConIva = 0.19;
    obtenerPrecioConIva * obtenerPrecioComision = 0.10;
    return obtenerPrecioComision;
}

Imports

import java.net.*;
import java.awt.event.*;
import javax.swing.

...
Continue reading "Java Sales System: Fixing Code for Personal and Phone Sales" »

Arquitetura e Instruções do Microcontrolador 8051: Guia de Pinagem e Conjunto de Instruções

Computer science8.09 KB

Do ponto de vista funcional, as instruções da família de processadores 8051 são agrupadas em cinco grandes grupos: "Operações Aritméticas", "Operações Lógicas", "Transferências de Dados", "Processamento Booleano Bit a Bit" e "Transferência e Salto de Controlo".

Operações Aritméticas

Instrução ADD

Quando é executada uma instrução deste tipo, o conteúdo do acumulador é somado com um segundo operando, e o resultado da operação é guardado no registo acumulador. O segundo operando, byte, é um endereço que pode ser especificado de qualquer uma das seguintes formas:

  • Direto: exemplo, ADD A, 20H;
  • Por registo: exemplo, ADD A, R7;
  • Indireto por registo: exemplo, ADD A, @R0;
  • Imediato: exemplo, ADD A, #20H.

Instruções INC e DEC

Quando...

Continue reading "Arquitetura e Instruções do Microcontrolador 8051: Guia de Pinagem e Conjunto de Instruções" »

8051 Microcontroller: Memory Organization and ALU

Computer science3 KB

1.2. Organization of Memory

On Intel's 8051 family, program storage and data are physically separate. Both data and programs can be stored in internal or external memory devices. To identify external memory locations accessed during instruction execution, the microprocessor generates pulses on the ALE (Address Latch Enable) line and controls the PSEN (Program Store Enable) output state.

1.2.1. Program Memory

In 8051-based systems, the selection of program memory (internal and external) is determined by the hardware designer. The microprocessor accesses external memory only if the EA (External Access Enable) pin is connected to ground. If EA is high (connected to Vcc), the microprocessor uses its internal memory for low addresses and external memory...

Continue reading "8051 Microcontroller: Memory Organization and ALU" »