1. Create an app with a button and a text field. Display the current count in the text field (display 0 when the app loads). CODE EACH OF THESE SUB QUESTIONS AS SEPARATE APPS!
a. Count up to 20, then automatically start back at 1 (instead of reaching 21).
b. Count up by one for each button press for the first 10 presses, then count up by 2 for the next 10 presses, 3 for the next 10, and so on.
c. Count up using the Fibonacci sequence. This sequence starts at 1. On the first press add 1, then 2, then 3, then 5, then 8, and so on.
d. Count up from 1 to 10 then back down from 10 to 1, adding or subtracting 1 for each button press. When it hits 1, start counting back up again.
*GUI in Java
//PressButton.java
// *******************************************
import java.awt.Button;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
//Extending Frame and Implementing
// ActionListener and Runnbale for Thread
public class PressButton extends Frame implements
Runnable,ActionListener{
//Declaration of Buttons,TextFields and
Variables
Button b1;
TextField t1;
int sum=1;
Thread th; //Declaration of thread
int count=0,count1=1;
static int i=1;
//Constructor
public PressButton(){
t1=new
TextField("0");
t1.setBounds(50,50, 150,20);
b1=new Button("Press");
b1.setBounds(50,100,60,30);
add(t1);add(b1);
//Window Closing Adapter method
addWindowListener(new WindowAdapter() {
public void
windowClosing(WindowEvent we){
dispose();
}
});
//Button Action
b1.addActionListener(this);
}
public static void main(String[] args) {
//Creating a Frame
PressButton pb = new
PressButton();
pb.setSize(300, 300);
pb.setVisible(true);
pb.setTitle("Press Button");
pb.setLayout(new
FlowLayout());
}
//Action Performed when button clicks
public void actionPerformed(ActionEvent ae) {
th = new Thread(this); // Thread is
initializing
th.start(); //thread is started
with run() when button clicks
}
//Task-A Get back to 1 when 20
reaches
public void run() {
if(sum==20){
sum = 1;
t1.setText(new
Integer(sum).toString());
}
else{
sum =
Integer.parseInt(t1.getText().toString())+1;
t1.setText(new
Integer(sum).toString());
}
}
//Task-B Count by
10..1,2,3...
/*public void run(){
if(count%10==0 &&
count>0){
i++;
}
sum =
Integer.parseInt(t1.getText().toString())+i;
t1.setText(new
Integer(sum).toString());
count++;
}*/
//Task-C Fibonacci Count
/*public void run(){
sum = count+count1;
//sum =
Integer.parseInt(t1.getText().toString())+i;
t1.setText(new
Integer(sum).toString());
count=count1;
count1=Integer.parseInt(t1.getText().toString());
}*/
//Task-D Adding or Substracting
/*public void run(){
if(count<10){
sum =
Integer.parseInt(t1.getText().toString())+1;
t1.setText(new
Integer(sum).toString());
}else{
sum =
Integer.parseInt(t1.getText().toString())-1;
t1.setText(new
Integer(sum).toString());
if(sum==1){
count=0;
}
}
count++;
}*/
}
// **************************************
//Output:
Note: From the above program, i have created four run() methods for four tasks as specified as A,B,C and D
So, please uncomment any one of the tasks to see output individually. Never uncomment more than one.
1. Create an app with a button and a text field. Display the current count in...
For this question you will need to complete the methods to create a JavaFX GUI application that implements two String analysis algorithms. Each algorithm is activated when its associated button is pressed. They both take their input from the text typed by the user in a TextField and they both display their output via a Text component at the bottom of the GUI, which is initialized to “Choose a string methods as indicated in the partially completed class shown after...
Please help me~~~~ using javascript, Display a text field so that the user can enter an integer. Display two buttons “Start Animation” and “Stop Animation”. When the button “Start Animation” is clicked, the web page displays an animated times table in the following manner. For example, if the user entered the number 6, then the animation displays 6 x 1 = 6, one second later it replaces it with 6 x 2 = 12, one second later it replaces it...
solve 1 2 and 3 Problems 1 and 2 require a 7-segment display. You may want to re-use the display driver you developed in Lab 3. Use a push-button as the clock - the pushbuttons are debounced, whereas the slide switches are not. Remember to provide columnsfor lest data in your state lables (use the observed next state as the test data in problems I and 2, and the observed next state and preseni output as the lest data in...
1. Describe how a Windows Store app is displayed differently from a Windows application. 2. Instead of icons, Windows Store apps are launched by tapping or clicking _________. 3. What is the file extension of an app package in the Windows Store? 4. What does touch-first mean when using Windows Store apps? 5. How many touch points does a Windows 8 device typically have? 6. Windows Store apps can be written in which programming languages? 7. What does XAML stand...
Design C-1 (modulo-10 up-counter): Using the behavioral VHDL coding, create an up-counter to count upward. The up counter has the following control inputs En.reset, CLK. The counting outputs are Q0, O1, Q2. and O3 reset clears the outputs of the counter to 0. En enables the counting when En-1. When En-0, the counter stops. The counter sequentially counts all the possible numbers and loops again, from 0 to 9, back to 0 and 9, etc Design C-2: Ten-second Counter with...
Python 3+ (using TKinter): 1.) Develop new TKinter GUI widget class Ed that can be used to teach first-graders addition and subtraction. The GUI should contain two Entry widgets and a Button widget labeled "Enter". At start-up, your program should generate (1) two single-digit pseudorandom numbers a and b and (2) an operation op, which could be addition or subtraction—with equal likelihood—using the randrange() function in the random module. The expression a op b will then be displayed in the...
This is python3. Please help me out. Develop the following GUI interface to allow the user to specify the number of rows and number of columns of cards to be shown to the user. Show default values 2 and 2 for number of rows and number of columns. The buttons "New Game" and "Turn Over" span two column-cells each. Fig 1. The GUI when the program first starts. When the user clicks the "New Game" button, the program will read...
C# Temp. Converter program. Create a Celsius and Fahrenheit Temperature Converter application. The application must have 2 Labels (each one of them assigned only to Celsius and Fahrenheit), 2 TextBoxes (each one of them assigned only to Celsius and Fahrenheit), only 1 Convert Button, 1 Clear Button, and 1 Exit Button. Also, 1 Error message label which will display the error messages. The application should only allow the user to enter the desired temperature just in one of the TextBoxes...
The Fibonacci sequence is the sequence of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, … The next number is found by adding up the two numbers before it. For example, the 2 is found by adding the two numbers before it (1+1). The 3 is found by adding the two numbers before it (1+2). The 5 is found by adding the two numbers before it (2+3), and so on! Each number in the sequence is called...
Fibonacci Sequence The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... The next number is found by adding up the two numbers before it. The 2 is found by adding the two numbers before it (1+1) The 3 is found by adding the two numbers before it (1+2), And the 5 is (2+3), and so on! Example: the next number in the sequence above is 21+34 = 55 Source:...