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)...
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...
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...
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
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,...
Need these written in Java script please Problem 1: Given an array A[0 ... n-1], where...
Need these written in Java script please Problem 1: Given an array A[0 ... n-1], where each element of the array represents a vote in the election. Assume that each vote is given as integers representing the ID of the chosen candidate. Write the code determining who wins the election. Problem 2: How do we find the number which appeared maximum number of times in an array?
Task #1 The if Statement, Comparing Strings, and Flags (JAVA using Eclipse IDE 14) Create the...
Task #1 The if Statement, Comparing Strings, and Flags (JAVA using Eclipse IDE 14) Create the file PizzaOrder.java. Prompt the user to input the type of pizza that they want to order. In the end, you should print out the final order and price. Here is a sample output. Welcome to May and Adam’s Pizzeria Enter your first name: Amy Pizza Size(inches)     Cost         10            $10.99         12            $12.99         14            $14.99         16            $16.99 What size pizza would you...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT