Question

In: Computer Science

For java script 1. Make a set of buttons that demonstrate strings. Feel free to combine...

For java script

1. Make a set of buttons that demonstrate strings. Feel free to combine these new buttons with the buttons of the previous HW if you like, but you don't have to.

2. Modify the button styles

3. Add a for loop, a while loop, and a do while loop. These should be activated by buttons to demonstrate the loops.

Solutions

Expert Solution

<!DOCTYPE html>
<html>
<body>

<h1>Set of Buttons</h1>

<button onclick="myFunction()">Click me</button>

<p id="demo"></p>

<script>
function myFunction() {
document.getElementById("demo").innerHTML = "BMW", "Volvo", "Saab", "Ford", "Fiat", "Audi";
}
</script>
<script>
var cars= {"BMW", "Volvo", "Saab", "Ford", "Fiat", "Audi"};
var text = "";
var i;
for (i = 0; i < cars.length; i++) {
text += cars[i] + "<br>";
}
document.getElementById("demo").innerHTML = text;
</script>


<button onclick="myFunction1()">Click me</button>

<p id="demo1"></p>

<script>
function myFunction1() {
document.getElementById("demo1").innerHTML = "BMW", "Volvo", "Saab", "Ford", "Fiat", "Audi";
}
</script>
<script>
var cars= {"BMW", "Volvo", "Saab", "Ford", "Fiat", "Audi"};
var text = "";
var i;
while (i < cars.length) {
text += cars[i] + "<br>";
}
document.getElementById("demo").innerHTML = text;
</script>


<button onclick="myFunction2()">Click me</button>

<p id="demo2"></p>

<script>
function myFunction2() {
document.getElementById("demo2").innerHTML = "BMW", "Volvo", "Saab", "Ford", "Fiat", "Audi";
}
</script>
<script>
var cars= {"BMW", "Volvo", "Saab", "Ford", "Fiat", "Audi"};
var text = "";
var i;
do {
text += cars[i] + "<br>";
}
while(i<cars.length)
document.getElementById("demo").innerHTML = text;
</script>


</body>
</html>


Related Solutions

Advance Macroeconomic Please feel free to make use of graphs as you see fit 1. a....
Advance Macroeconomic Please feel free to make use of graphs as you see fit 1. a. Provide a detailed analysis of the four crucial components of the Classical Model: the labor market, Say’s Law, the loanable funds market and the quantity theory of money. b. While making use of these four components, provide an explanation of why this model implies that there is no need for any aggregate demand management to maintain full employment. (Please emphasize, in particular, the role...
3. Write a Java program that generates a set of random strings from a given string...
3. Write a Java program that generates a set of random strings from a given string of same length where no character is ever repeated and characters belong to the original string. Examples Input: “Hello World” Output: “World oHlel”
Create a Java Swing form that will have two Buttons: (1) the first linked to an...
Create a Java Swing form that will have two Buttons: (1) the first linked to an event handler to write data from two TextFields on the form to an output file; and (2) the other with an event handler to read data from the same file as input and write output to a binary ObjectOutputStream file.
6.6 Parsing strings (Java) (1) Prompt the user for a string that contains two strings separated...
6.6 Parsing strings (Java) (1) Prompt the user for a string that contains two strings separated by a comma. (1 pt) Examples of strings that can be accepted: Jill, Allen Jill , Allen Jill,Allen Ex: Enter input string: Jill, Allen (2) Report an error if the input string does not contain a comma. Continue to prompt until a valid string is entered. Note: If the input contains a comma, then assume that the input also contains two strings. (2 pts)...
A. combine the following sentences to make a compound or complet sentence. 1) Methamphetamine is a...
A. combine the following sentences to make a compound or complet sentence. 1) Methamphetamine is a very addictive drug. Many meth addicts die each year. 2) Treating patients after they become sick costs a lot of money. preventive care is nearly cost-free 3)When she lost her job in spring, sade applied everywhere for a new one. she resorted to applying for unemployment. B. combine the following sentences to make a compound sentence with a coordinating conjuction. 1) Shoppers are not...
Java 1.Write a method removeEvenLength that takes an ArrayList of Strings as a parameter and that...
Java 1.Write a method removeEvenLength that takes an ArrayList of Strings as a parameter and that removes all of the strings of even length from the list. 2. Given the following Vehicle interface and client program in the Car class: public interface Vehicle{ public void move(); } public class Car implements Vehicle{ public static void main(String args[]) Vehicle v = new Vehicle(); // vehicle declaration } The above declaration is valid? True or False? 3. Java permits a class to...
1. Write a Post system that defines the set of binary strings of odd length that...
1. Write a Post system that defines the set of binary strings of odd length that have a “x” as the middle character and "x" is a string
1 Demonstrate the use of local variables in a Java program that has 1 function 2...
1 Demonstrate the use of local variables in a Java program that has 1 function 2 Demonstrate the use of overloaded methods each has three primitive parameters two methods computes and returns the product to the calling method for printing one method computes and prints the product; does not return a result 3 Demonstrate the use of overloaded constructors Three constructors each initialize two variables Three methods, 1 computes the radius of a circle, 1 computes the area of a...
Java 1. Program Specification This will focus on strengthening your skills with manipulating Strings. The String...
Java 1. Program Specification This will focus on strengthening your skills with manipulating Strings. The String class provides many useful methods, in which this assignment will give you further practice with. You will read in dates in a variety of different formats, parse the dates, and then print them out in a converted format. The dates will be entered in one line by the user, and they will be separated by the word “and”. 2. Date formats Your program will...
USE C# to write this. 1.To the capsule, add a script called “MoveIt”. This will make...
USE C# to write this. 1.To the capsule, add a script called “MoveIt”. This will make the capsule move repeatedly between (3, 0, 0) and (-3, 0, 0), moving 1 unit per second, moving in the positive direction initially. [Note: The capsule should move toward (3,0,0) from its initial location of (0,1,0) and then move toward (-3,0,0), etc.] 2.To the yellow cube, add a script called “RotateIt”. This will make the cube rotate (30, 60, 90) per second. 3. Lastly,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT