The document describes three Java programs for calculating simple mathematical operations and values:
1. A calculator program that allows users to enter two numbers and select a mathematical operation (addition, subtraction, multiplication, or division) to perform the calculation.
2. A program that calculates severance pay values based on a user's time of service and monthly salary.
3. A program that provides budget estimates for different construction/remodeling jobs based on area size and material selections.
Workshop JavaScript Testing. Frameworks. Client vs Server Testing. Jasmine. Chai. Nock. Sinon. Spec Runners: Karma. TDD. Code coverage. Building a testable JS app.
Presentado por ing: Raúl Delgado y Mario García
Workshop JavaScript Testing. Frameworks. Client vs Server Testing. Jasmine. Chai. Nock. Sinon. Spec Runners: Karma. TDD. Code coverage. Building a testable JS app.
Presentado por ing: Raúl Delgado y Mario García
In 2008 Android app code had a lot of boilerplate, and was very error prone.
More code.. more bugs!
Now it doesn't have to be... but that is an option that each developer needs to take!
An overview how to realize code generation of languages on the JVM that implement other class layouts than the Java programming languages. As an example, the inline-mock-maker for Mockito is discussed which supports languages like Kotlin that make any property final by default.
In JS: CLASS <=> Constructor FN
new FN() => FN() { this }
FN = CLASS (FN = FN, FN = DATA)
Objects
Prototype / __proto__
Inheritence
Rewriting / Augmenting
built in objects
In this talk we are going tο… talk about what unit testing is, how you can apply it to ensure your code works as expected and how TDD can help you write new and refactor existing code. Also about how to decide what to test and how you can test real world iOS apps. Finally, we will go through a few tips and tricks that made unit testing in Swift and Xcode 'click' for me and can hopefully help you too.
Practical JavaScript Programming - Session 6/8Wilson Su
JavaScript is one of the most popular skills in today’s job market. It allows you to create both client- and server-side applications quickly and easily. Having a solid understanding of this powerful and versatile language is essential to anyone who uses it.
“Practical JavaScript Programming” does not only focus on best practices, but also introduces the fundamental concepts. This course will take you from JavaScript basics to advanced. You’ll learn about topics like Data Types, Functions, Events, AJAX and more.
In 2008 Android app code had a lot of boilerplate, and was very error prone.
More code.. more bugs!
Now it doesn't have to be... but that is an option that each developer needs to take!
An overview how to realize code generation of languages on the JVM that implement other class layouts than the Java programming languages. As an example, the inline-mock-maker for Mockito is discussed which supports languages like Kotlin that make any property final by default.
In JS: CLASS <=> Constructor FN
new FN() => FN() { this }
FN = CLASS (FN = FN, FN = DATA)
Objects
Prototype / __proto__
Inheritence
Rewriting / Augmenting
built in objects
In this talk we are going tο… talk about what unit testing is, how you can apply it to ensure your code works as expected and how TDD can help you write new and refactor existing code. Also about how to decide what to test and how you can test real world iOS apps. Finally, we will go through a few tips and tricks that made unit testing in Swift and Xcode 'click' for me and can hopefully help you too.
Practical JavaScript Programming - Session 6/8Wilson Su
JavaScript is one of the most popular skills in today’s job market. It allows you to create both client- and server-side applications quickly and easily. Having a solid understanding of this powerful and versatile language is essential to anyone who uses it.
“Practical JavaScript Programming” does not only focus on best practices, but also introduces the fundamental concepts. This course will take you from JavaScript basics to advanced. You’ll learn about topics like Data Types, Functions, Events, AJAX and more.
Java!!!!!Create a program that authenticates username and password.pdfarvindarora20042013
Java!!!!!
Create a program that authenticates username and password. The program should have a clear
and submit button. If you click sumbit it will go to a new JFrame. The new Jframe contain a
menu button( that does nothing) and a logout button that exits the program.
Solution
import java.sql.*;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.swing.*;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Administrator
*/
public class Login extends javax.swing.JFrame {
/**
* Creates new form Login
*/
public Login() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings(\"unchecked\")
//
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jPasswordField1 = new javax.swing.JPasswordField();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setFont(new java.awt.Font(\"Tahoma\", 1, 18)); // NOI18N
jLabel1.setText(\"Hiding Data Cloud \");
jLabel2.setFont(new java.awt.Font(\"Tahoma\", 1, 12)); // NOI18N
jLabel2.setText(\"User Name : \");
jLabel3.setFont(new java.awt.Font(\"Tahoma\", 1, 12)); // NOI18N
jLabel3.setText(\"Password :\");
jButton1.setText(\"Login\");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(96, 96, 96)
.addComponent(jLabel1))
.addGroup(layout.createSequentialGroup()
.addGap(69, 69, 69)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 134,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel3)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton1)
.addComponent(jPasswordField1))))))
.addContainerGap(112, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(35, 35, 35)
.addComponent(jLabel1)
.addGap(53, 53, 53)
.addGroup(layout.creat.
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docxmary772
CodeZip/ButtonDemo.javaCodeZip/ButtonDemo.java// Demonstrate a push button and handle action events.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
publicclassButtonDemoimplementsActionListener{
JLabel jlab;
JTextField jtf;
ButtonDemo(){
// Create a new JFrame container.
JFrame jfrm =newJFrame("A Button Example");
// Specify FlowLayout for the layout manager.
jfrm.setLayout(newFlowLayout());
// Give the frame an initial size.
jfrm.setSize(220,90);
// Terminate the program when the user closes the application.
jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Make two buttons.
JButton jbtnUp =newJButton("Up");
JButton jbtnDown =newJButton("Down");
// Create a text field.
jtf =newJTextField(10);
// Add action listeners.
jbtnUp.addActionListener(this);
jbtnDown.addActionListener(this);
// Add the buttons to the content pane.
jfrm.add(jbtnUp);
jfrm.add(jbtnDown);
jfrm.add(jtf);
// Create a label.
jlab =newJLabel("Press a button.");
// Add the label to the frame.
jfrm.add(jlab);
// Display the frame.
jfrm.setVisible(true);
}
// Handle button events.
publicvoid actionPerformed(ActionEvent ae){
if(ae.getActionCommand().equals("Up")){
jlab.setText("You pressed Up.");
FileClock clock1=newFileClock(jtf);
Thread thread1=newThread(clock1);
thread1.start();
}
else
jlab.setText("You pressed down. ");
}
publicstaticvoid main(String args[]){
// Create the frame on the event dispatching thread.
SwingUtilities.invokeLater(newRunnable(){
publicvoid run(){
newButtonDemo();
}
});
}
}
CodeZip/CBDemo.javaCodeZip/CBDemo.java// Demonstrate check boxes.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
publicclassCBDemoimplementsItemListener{
JLabel jlabSelected;
JLabel jlabChanged;
JCheckBox jcbAlpha;
JCheckBox jcbBeta;
JCheckBox jcbGamma;
CBDemo(){
// Create a new JFrame container.
JFrame jfrm =newJFrame("Demonstrate Check Boxes");
// Specify FlowLayout for the layout manager.
jfrm.setLayout(newFlowLayout());
// Give the frame an initial size.
jfrm.setSize(280,120);
// Terminate the program when the user closes the application.
jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Create empty labels.
jlabSelected =newJLabel("");
jlabChanged =newJLabel("");
// Make check boxes.
jcbAlpha =newJCheckBox("Alpha");
jcbBeta =newJCheckBox("Beta");
jcbGamma =newJCheckBox("Gamma");
// Events generated by the check boxes
// are handled in common by the itemStateChanged()
// method implemented by CBDemo.
jcbAlpha.addItemListener(this);
jcbBeta.addItemListener(this);
jcbGamma.addItemListener(this);
// Add checkboxes and labels to the content pane.
jfrm.add(jcbAlpha);
jfrm.add(jcbBeta);
jfrm.add(jcbGamma);
jfrm.add(jlabChanged);
jfrm.add(jlabSelected);
// Display the frame.
jfrm.setVisible(true);
}
// This is the handler for the check boxes..
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docxmccormicknadine86
CodeZip/ButtonDemo.javaCodeZip/ButtonDemo.java// Demonstrate a push button and handle action events.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
publicclassButtonDemoimplementsActionListener{
JLabel jlab;
JTextField jtf;
ButtonDemo(){
// Create a new JFrame container.
JFrame jfrm =newJFrame("A Button Example");
// Specify FlowLayout for the layout manager.
jfrm.setLayout(newFlowLayout());
// Give the frame an initial size.
jfrm.setSize(220,90);
// Terminate the program when the user closes the application.
jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Make two buttons.
JButton jbtnUp =newJButton("Up");
JButton jbtnDown =newJButton("Down");
// Create a text field.
jtf =newJTextField(10);
// Add action listeners.
jbtnUp.addActionListener(this);
jbtnDown.addActionListener(this);
// Add the buttons to the content pane.
jfrm.add(jbtnUp);
jfrm.add(jbtnDown);
jfrm.add(jtf);
// Create a label.
jlab =newJLabel("Press a button.");
// Add the label to the frame.
jfrm.add(jlab);
// Display the frame.
jfrm.setVisible(true);
}
// Handle button events.
publicvoid actionPerformed(ActionEvent ae){
if(ae.getActionCommand().equals("Up")){
jlab.setText("You pressed Up.");
FileClock clock1=newFileClock(jtf);
Thread thread1=newThread(clock1);
thread1.start();
}
else
jlab.setText("You pressed down. ");
}
publicstaticvoid main(String args[]){
// Create the frame on the event dispatching thread.
SwingUtilities.invokeLater(newRunnable(){
publicvoid run(){
newButtonDemo();
}
});
}
}
CodeZip/CBDemo.javaCodeZip/CBDemo.java// Demonstrate check boxes.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
publicclassCBDemoimplementsItemListener{
JLabel jlabSelected;
JLabel jlabChanged;
JCheckBox jcbAlpha;
JCheckBox jcbBeta;
JCheckBox jcbGamma;
CBDemo(){
// Create a new JFrame container.
JFrame jfrm =newJFrame("Demonstrate Check Boxes");
// Specify FlowLayout for the layout manager.
jfrm.setLayout(newFlowLayout());
// Give the frame an initial size.
jfrm.setSize(280,120);
// Terminate the program when the user closes the application.
jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Create empty labels.
jlabSelected =newJLabel("");
jlabChanged =newJLabel("");
// Make check boxes.
jcbAlpha =newJCheckBox("Alpha");
jcbBeta =newJCheckBox("Beta");
jcbGamma =newJCheckBox("Gamma");
// Events generated by the check boxes
// are handled in common by the itemStateChanged()
// method implemented by CBDemo.
jcbAlpha.addItemListener(this);
jcbBeta.addItemListener(this);
jcbGamma.addItemListener(this);
// Add checkboxes and labels to the content pane.
jfrm.add(jcbAlpha);
jfrm.add(jcbBeta);
jfrm.add(jcbGamma);
jfrm.add(jlabChanged);
jfrm.add(jlabSelected);
// Display the frame.
jfrm.setVisible(true);
}
// This is the handler for the check boxes. ...
JavaFX 8 est disponible depuis mars 2014 et apporte son lot de nouveautés. Gradle est en version 2 depuis juillet 2014. Deux technologies plus que prometteuses: JavaFX donne un coup de jeune au développement d’applications desktop en Java en apportant un navigateur web intégré, le support des WebSockets, de la 3D, et bien d’autres. Gradle est l’outil de d’automatisation de build à la mode, apportant de superbes possibilités par rapport rapport à maven, outil vieillissant, grâce à l’engouement de la communauté vis à vis de cet outil mais aussi par le fait de la technologie utilisée en son sein: groovy. Venez découvrir comment il est possible de réaliser rapidement une application à la mode en JavaFX avec un outil à la mode également. Bref venez à une session trendy.
Ten useful JavaScript tips & best practicesAnkit Rastogi
In this presentation there are ten useful JavaScript techniques which can be included in your application easily with less friction along with some AngularJs tips and best practices as a bonus. These tips and best practices are accompanied by examples & will cover script loading, design pattern, performance optimization and other areas.
Since best practices are very subjective topics, proper benchmarking needs to be done.
Object-Oriented JavaScript presentation given at the 2010 ESRI Developer Summit. Code and slides are also available at http://github.com/kvangork/OOJS-Presentation
Find me on twitter @kvangork
or my blog http://prng.vangorkom.org
Object-Oriented JavaScript presentation given at ESRI's 2010 Developer Summit. Slides and code available at http://github.com/kvangork/OOJS-Presentation
Find me on twitter @kvangork
or at my blog: http://prng.vangorkom.org
Refactoring can either completely disrupt your project or make you go faster. This presentation will help you to avoid some pitfalls.
It also demonstrates refactorings that you could apply straight away to make your code better.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
Neuro-symbolic (NeSy) AI is on the rise. However, simply machine learning on just any symbolic structure is not sufficient to really harvest the gains of NeSy. These will only be gained when the symbolic structures have an actual semantics. I give an operational definition of semantics as “predictable inference”.
All of this illustrated with link prediction over knowledge graphs, but the argument is general.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
2. EXERCICIO 1 – CALCULADORA
Source
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package calculadora;
/**
*
* @author CAO VeraCymbron
*/
public class Calculadora extends javax.swing.JFrame {
/**
* Creates new form Calculadora
*/
public Calculadora() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
valor1 = new javax.swing.JLabel();
valor2 = new javax.swing.JLabel();
TF2 = new javax.swing.JTextField();
3. bsoma = new javax.swing.JButton();
TF3 = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
bdivisao = new javax.swing.JButton();
bsubtraccao = new javax.swing.JButton();
bmultiplicacao = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
valor1.setText("Numero1");
valor1.setToolTipText("");
valor2.setText("Numero2");
TF2.setToolTipText("");
bsoma.setMnemonic('s');
bsoma.setText("Soma");
bsoma.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bsomaActionPerformed(evt);
}
});
TF3.setToolTipText("");
jLabel3.setText("Resultado:");
bdivisao.setMnemonic('s');
bdivisao.setText("Divisão");
bdivisao.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bdivisaoActionPerformed(evt);
}
});
bsubtraccao.setMnemonic('s');
bsubtraccao.setText("Subtracção");
bsubtraccao.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bsubtraccaoActionPerformed(evt);
}
});
bmultiplicacao.setMnemonic('s');
bmultiplicacao.setText("Multiplicação");
bmultiplicacao.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bmultiplicacaoActionPerformed(evt);
}
});
5. .addComponent(TF2, javax.swing.GroupLayout.PREFERRED_SIZE, 25,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(bsoma)
.addComponent(bsubtraccao))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(bdivisao)
.addComponent(bmultiplicacao))
.addGap(18, 18, 18)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 22,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(122, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void bsomaActionPerformed(java.awt.event.ActionEvent evt) {
double num1, num2, res; //variáveis auxiliares
//converter o numero digitado em Float
num1 = Double.parseDouble(TF2.getText());
num2 = Double.parseDouble (TF3.getText());
res = num1 + num2;
//converte o resultado em String e mostrar
jLabel3.setText(String.valueOf("Resultado: " +res));
TF2.setText(" ");//Limpar o JTextField
TF3.setText(" ");
TF3.requestFocus();//muda o foco para o JTextField1
}
private void bdivisaoActionPerformed(java.awt.event.ActionEvent evt) {
double num1, num2, res; //variáveis auxiliares
//converter o numero digitado em Float
num1 = Double.parseDouble(TF2.getText());
num2 = Double.parseDouble (TF3.getText());
res = num1 / num2;
//converte o resultado em String e mostrar
jLabel3.setText(String.valueOf("Resultado: " +res));
TF2.setText(" ");//Limpar o JTextField
TF3.setText(" ");
TF3.requestFocus();//muda o foco para o JTextField1
}
private void bsubtraccaoActionPerformed(java.awt.event.ActionEvent evt) {
double num1, num2, res; //variáveis auxiliares
//converter o numero digitado em Float
num1 = Double.parseDouble(TF2.getText());
num2 = Double.parseDouble (TF3.getText());
6. res = num1 - num2;
//converte o resultado em String e mostrar
jLabel3.setText(String.valueOf("Resultado: " +res));
TF2.setText(" ");//Limpar o JTextField
TF3.setText(" ");
TF3.requestFocus();//muda o foco para o JTextField1
}
private void bmultiplicacaoActionPerformed(java.awt.event.ActionEvent evt) {
double num1, num2, res; //variáveis auxiliares
//converter o numero digitado em Float
num1 = Double.parseDouble(TF2.getText());
num2 = Double.parseDouble (TF3.getText());
res = num1 * num2;
//converte o resultado em String e mostrar
jLabel3.setText(String.valueOf("Resultado: " +res));
TF2.setText(" ");//Limpar o JTextField
TF3.setText(" ");
TF3.requestFocus();//muda o foco para o JTextField1
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Calculadora.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Calculadora.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (IllegalAccessException ex) {
7. java.util.logging.Logger.getLogger(Calculadora.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Calculadora.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Calculadora().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JTextField TF2;
private javax.swing.JTextField TF3;
private javax.swing.JButton bdivisao;
private javax.swing.JButton bmultiplicacao;
private javax.swing.JButton bsoma;
private javax.swing.JButton bsubtraccao;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel valor1;
private javax.swing.JLabel valor2;
// End of variables declaration
}
EXERCICIO 2 – CALCULAR VALOR DA INDEMINIZAÇÃO
SOURCE
/*
8. * To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package valorindeminizacao;
/**
*
* @author CAO 12
*/
public class ValorIndemnizacao extends javax.swing.JFrame {
/**
* Creates new form ValorIndemnizacao
*/
public ValorIndemnizacao() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
valor1 = new javax.swing.JLabel();
valor2 = new javax.swing.JLabel();
num1 = new javax.swing.JTextField();
num2 = new javax.swing.JTextField();
num3 = new javax.swing.JTextField();
calcular = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
valor3 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
valor1.setText("Tempo de serviço (MESES)");
valor2.setText("Vencimento mensal");
calcular.setText("Cacular");
calcular.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
calcularActionPerformed(evt);
}
});
jLabel4.setText("Valor da Indemnização é :");
valor3.setText("No caso de ter dias de férias por gozar indique");
10. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(valor3)
.addComponent(num3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(calcular)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 23,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(149, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void calcularActionPerformed(java.awt.event.ActionEvent evt) {
double valor1, valor2, valor3, valor = 0;
//variáveis auxiliares
//converter o numero digitado em Float
valor1 = Double.parseDouble(num1.getText());
valor2 = Double.parseDouble (num2.getText());
valor3 = Double.parseDouble (num3.getText());
if (valor1<=6) {
valor = ((valor1*3*valor2)/30)+((valor3*valor2)/30);
}
else
if (valor1 >=7) {
valor = ((valor1*2*valor2)/30)+((valor3*valor2)/30);
}
//converte o resultado em String e mostrar
jLabel4.setText(String.valueOf("O valor da indemnização é: " +valor+ "€"));
num1.setText(" ");//Limpar o JTextField
num2.setText(" ");
num3.setText(" ");
num1.requestFocus();//muda o foco para o JTextField1
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
12. EXERCICIO 3 – ORÇAMENTO
SOURCE
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package orcamento;
import javax.swing.JComboBox;
/**
*
* @author CAO 12
*/
public class Orcamento extends javax.swing.JFrame {
/**
* Creates new form Orcamento
*/
public Orcamento() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
13. private void initComponents() {
jComboBox2 = new javax.swing.JComboBox();
area = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
num1 = new javax.swing.JTextField();
saida = new javax.swing.JLabel();
jcomboBox1 = new javax.swing.JComboBox();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "->",
"Estuco", "Teto falso com Plauduro normal", "Teto falso com Plauduro hidrofugado" }));
jComboBox2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox2ActionPerformed(evt);
}
});
area.setText("Área m2");
jLabel2.setText("Seleccione o serviço pretendido");
saida.setText("O valor é:");
jcomboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "23", "16"
}));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 173,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(area)
.addGap(18, 18, 18)
.addComponent(num1, javax.swing.GroupLayout.PREFERRED_SIZE, 63,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 369,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(saida, javax.swing.GroupLayout.PREFERRED_SIZE, 343,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jcomboBox1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
15. //converte o resultado em String e mostrar
saida.setText(String.valueOf("O valor do serviço é: " +resultado+"€"));
num1.setText(" ");//Limpar o JTextField
num1.requestFocus();//muda o foco para o JTextField1
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Orcamento.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Orcamento.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Orcamento.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Orcamento.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Orcamento().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel area;
private javax.swing.JComboBox jComboBox2;
16. private javax.swing.JLabel jLabel2;
private javax.swing.JComboBox jcomboBox1;
private javax.swing.JTextField num1;
private javax.swing.JLabel saida;
// End of variables declaration
}
EXERCICIO 4 – CALCULO DA MASSA CORPORAL
SOURCE
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package massacorporal;
/**
*
* @author CAO 12
*/
public class MASSACORPORAL extends javax.swing.JFrame {
/**
* Creates new form MASSACORPORAL
*/
public MASSACORPORAL() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.