Answer:
public int RandNum();
* Assuming it returns an integer
Explanation:
I believe you mean to write the function header of randNum.
To write the header of the function, we need to specify its return type, name, parenthesis and parameters inside the parenthesis - if exist.
If it returns an integer it should have int, if it returns a double it should have double in the header. In the answer, I assumed it returns an integer.
The name is already given, RandNum
Since, the function does not take any parameter, inside of the parenthesis will be empty.
[8:53 PM]
2) Create a button with label “true” , clicking on the button toggle the value from “true” => “false” and “false” => “true”.(edited)
techsith (patel) — 03/03/2021
3) Create a counter and a button. clicking on the button increments the counter by one. double clicking on the button resets the counter to 0
Answer:too many words ahhh
Explanation:
(assuming jsx)
function Buttons (props) {
return(
{props.counterValue}
counter
increment
reset
);
}
var counterValue = 1;
function addup(a){
if(counterValue + a <= 20){
counterValue += a;
} else if (counterValue + a > 20){
//do nothing
}
ReactDOM.render(
,
document.getElementById('root')
);
}
function reset() {
counterValue = 1;
ReactDOM.render(
,
document.getElementById('root')
);
}
Answer:
vowels = ("a", "e", "i", "o", "u")
word = input("Enter a word: ")
is_all = True
for c in vowels:
if c not in word:
is_all = False
if is_all == True:
print(word + " is a vowel word.")
else:
print(word + " is not a vowel word.")
Explanation:
Initialize a tuple, vowels, containing every vowel
Ask the user to enter a word
Initially, set the is_all as True. This will be used to check, if every vowel is in word or not.
Create a for loop that iterates through the vowels. Inside the loop, check if each vowel is in the word or not. If one of the vowel is not in the vowels, set the is_all as False.
When the loop is done, check the is_all. If it is True, the word is a vowel word. Otherwise, it is not a vowel word.
The statement which gives the sum of nickel and dime is written below :
total_coins = nickel_count + dime_count
The statement required is written using Python 3 :
deftotal(nickel_count, dime_count) :
total_coins =dime_count+nickel_count
print(total_coins)
total(100, 200)
#the function total takes in two arguments(number of nickels and number of dimes)
#assigns the varibale total_coins to the sum of nickel_count and dime_count
nickel_count = int(input('Enter count of nickel : '))
# User is prompted to enter number of nickels
dime_count = int(input('Enter count of dime : '))
# User is prompted to enter number of dimes
total_coins = nickel_count + dime_count
#assigns the varibale total_coins to the sum of nickel_count and dime_count
print(total_coins)
#outputs the value of total_coins
Learn more : brainly.com/question/17615351
Answer:
total_coins = nickel_count + dime_count
Explanation:
The statement that performs the operation in the question is total_coins = nickel_count + dime_count
Full Program (Written in Python)
nickel_count = int(input("Nickel Count: "))
dime_count = int(input("Dime Count: "))
total_coins = nickel_count + dime_count
print("Total coins: ",total_coins)
The first two lines prompt user for nickel and dime count respectively
The third line adds the two coins categories together
The last line prints the total count of coins
(2) Modify the given program to use a loop to output an arrow base of width arrowBaseWidth. Use a nested loop in which the inner loop draws the *’s, and the outer loop iterates a number of times equal to the height of the arrow base. (1 pt)
(3) Modify the given program to use a loop to output an arrow head of width arrowHeadWidth. Use a nested loop in which the inner loop draws the *’s, and the outer loop iterates a number of times equal to the height of the arrow head. (2 pts)
(4) Modify the given program to only accept an arrow head width that is larger than the arrow base width. Use a loop to continue prompting the user for an arrow head width until the value is larger than the arrow base width. (1 pt)
while (arrowHeadWidth <= arrowBaseWidth) {
// Prompt user for a valid arrow head value
}
Example output for arrowBaseHeight = 5, arrowBaseWidth = 2, and arrowHeadWidth = 4:
Enter arrow base height:
5
Enter arrow base width:
2
Enter arrow head width:
4
**
**
**
**
**
****
***
**
*
This is what I have:
import java.util.Scanner;
public class DrawHalfArrow
{
public static void main(String[] args)
{
Scanner scnr = new Scanner(System.in);
int arrowBaseHeight = 0;
int arrowBaseWidth = 0;
int arrowHeadWidth = 0;
System.out.println("Enter arrow base height:");
arrowBaseHeight = scnr.nextInt();
System.out.println("Enter arrow base width:");
arrowBaseWidth = scnr.nextInt();
while (arrowHeadWidth >= arrowBaseWidth)
{
System.out.println("Enter arrow head width:");
arrowHeadWidth = scnr.nextInt();
}
// Draw arrow base (height = 3, width = 2)
for(int i=0; i < arrowBaseHeight; ++i)
{
for(int j=0; j < arrowBaseWidth; ++j)
{
System.out.print("*");
}
System.out.println();
}
// Draw arrow head (width = 4)
for(int i=0; i < arrowHeadWidth; ++i)
{
for(int j=0; j < arrowHeadWidth-i; ++j)
{
System.out.print("*");
}
System.out.println();
}
return;
}
}
Answer:
The modified program in Java is as follows:
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int arrowHeadWidth, arrowBaseWidth, arrowBaseHeight;
System.out.print("Head Width: "); arrowHeadWidth = input.nextInt();
System.out.print("Base Width: "); arrowBaseWidth = input.nextInt();
System.out.print("Base Height: "); arrowBaseHeight = input.nextInt();
while (arrowHeadWidth <= arrowBaseWidth) {
System.out.print("Head Width: "); arrowHeadWidth = input.nextInt();
System.out.print("Base Width: "); arrowBaseWidth = input.nextInt(); }
for(int i = 0; i<arrowBaseHeight; i++){
for(int j = 0; j<arrowBaseWidth;j++){
System.out.print("*"); }
System.out.println(); }
for(int i = arrowHeadWidth; i>0;i--){
for(int j = 0; j<i;j++){
System.out.print("*"); }
System.out.println(); }
}
}
Explanation:
This declares the arrow dimensions
int arrowHeadWidth, arrowBaseWidth, arrowBaseHeight;
This get input for the head width
System.out.print("Head Width: "); arrowHeadWidth = input.nextInt();
This get input for the base width
System.out.print("Base Width: "); arrowBaseWidth = input.nextInt();
This get input for the base height
System.out.print("Base Height: "); arrowBaseHeight = input.nextInt();
This loop is repeated until the head width is greater than the base width
while (arrowHeadWidth <= arrowBaseWidth) {
System.out.print("Head Width: "); arrowHeadWidth = input.nextInt();
System.out.print("Base Width: "); arrowBaseWidth = input.nextInt(); }
This iterates through the base height
for(int i = 0; i<arrowBaseHeight; i++){
This iterates through the base width
for(int j = 0; j<arrowBaseWidth;j++){
This fills the base
System.out.print("*"); }
This prints a new line
System.out.println(); }
These iterate through the arrow head
for(int i = arrowHeadWidth; i>0;i--){
for(int j = 0; j<i;j++){
This fills the arrow head
System.out.print("*"); }
This prints a new line
System.out.println(); }
Answer:
Explanation:
The following code is written in Python. It is a function that takes in a string as a parameter, loops through the string and checks if each character is an alpha char. If it is, then it adds it to an output variable and when it is done looping it prints the output variable. A test case has been provided and the output can be seen in the attached image below.
def checkLetters(str):
output = ''
for char in str:
if char.isalpha() == True:
output += char
return output