Question
Choose 3 of 5 Problems to Solve
Need Soon as possible

Choose 3 of5 Problems to Solve (20 Point/Each) Problem l: Triangle Printing Program: Write an application that prints a right triangle with 1 to 8 rows. Prompt the user to enter an odd number in the range of 1 to 8 to specify the number of rows in the diamond. Add a validation loop to ensure the user does not enter an even number or a number outside the range of 1 to 8. Your program should then display a diamond of the appropriate size using asterisks(). Sample Output: Please enter a number between 1 and 8: g Invalid Number! Please enter a number between 1 and 8: 5 Problem 2: Grocery Checkout: Create a program which prompts the user for 4 pairs of values (Item Price, and Item Quantity), using a counter controlled loop. Keep running totals of the quantities, and the calculated values (price quantity), and display the total of all items, and the average price per item (totalPrice totalQuantity) Problem 3: Display a multiplication table of any row/column combination between 2 to 10. Prompt the user to enter two numbers (rows and columns) in the range of 2 to 10. Your program should then display the multiplication table using the inputted dimensions. Use two counter controlled loops, nested. Problem4: Yahtzee Roll Generate five (5) random numbers between 1 and 6, into 6 variables nl, through n6, and generate a list of the values. Determine if there is a pair of 6s within the set of values. Hint: int sixcounter-e; If (n1##6) ++sīxCounter; Problem 5: Display a menu stating various languages, and asking the user for a value between 1 and 8. Generate a welcome message based upon the number received. Use the following table for your solution: 1. French: Bonjour2. Spanish: Hola 5. Japanese: Koanichiwa 6. German: Gutep Tag 7. Korean: SR 8. Arabic: Ablan Sample Output: 3. Russian: Privet 4. Italian: Ciao 1. French 2. Spanish 3. Russian 4. Italian 5. Japanese 6. German 7. Korean 8. Arabic Please select the language (1-8) in which you want to display a greeting: 3 Ciao! Submission Instructions Post to Blackboard, the 3 java programs named ProblemN.jara (where N is the number of the problem), with a text or Word file containing all output (4 files total), zipped into one zip file. Optionally, you can put all functionality into one java file and one output file, and rip it.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

// Problem 1

import java.util.Scanner;
class Main {
public static void main(String[] args) {
// DECLARING variables
Scanner sc = new Scanner(System.in);
int n;
  
// taking user input
System.out.print("Please enter a number between 1 and 8: ");
n = sc.nextInt();
  
// Asking for user input as long as number is not between 1 and 8 or even
while(n%2 == 0 || n<1 || n>8)
{
System.out.print("Invalid Number! Please enter a number between 1 and 8: ");
n = sc.nextInt();
}
  
// looping for number of lines
for(int i=1; i<=n; i++)
{
// looping for printing asterisks in each line
for(int j=1; j<=i; j++)
{
System.out.print("*");
}
System.out.println();
}
}
}

/*SAMPLE OUTPUT

Please enter a number between 1 and 8: 9
Invalid Number! Please enter a number between 1 and 8: 4
Invalid Number! Please enter a number between 1 and 8: 5
*
**
***
****
*****

*/

import java.util.Scanner;
class Main {
public static void main(String[] args) {
// DECLARING variables
Scanner sc = new Scanner(System.in);
int m,n;
  
// taking user input
System.out.print("Please enter a number between 2 and 10: ");
m = sc.nextInt();
System.out.print("Please enter another number between 2 and 10: ");
n = sc.nextInt();
  
// for each row
for(int i=1; i<=m; i++)
{
// for each column
for(int j=1; j<=n; j++)
{
// multiplication value
System.out.printf("%4d",i*j);
}
System.out.println();
}
}
}

Please enter a number between 2 and 10: 7 Please enter another number between 2 and 10 10 1 2 3 45 6 78 9 10 2 4 6 8 10 12 14

import java.util.Scanner;
class Main {
public static void main(String[] args) {
// Declaring variables
int choice;
Scanner sc = new Scanner(System.in);
  
// prompting for input
System.out.println("1. French");
System.out.println("2. Spanish");
System.out.println("3. Russian");
System.out.println("4. Italian");
System.out.println("5. Japanese");
System.out.println("6. German");
System.out.println("7. Korean");
System.out.println("8. Arabic");
  
System.out.print("\nPlease select the language (1-8) in which you want to display a greeting: ");
  
// taking user input
choice = sc.nextInt();
  
// printing message based on the choice by user
if(choice == 1)
System.out.print("Bonjour");
else if(choice == 2)
System.out.print("Hola");
else if(choice == 3)
System.out.print("Privet");
else if(choice == 4)
System.out.print("Ciao");
else if(choice == 5)
System.out.print("Lonnichiwa");
else if(choice == 6)
System.out.print("Guren Tag");
else if(choice == 7)
System.out.print("Anyoung");
else if(choice == 8)
System.out.print("Ahlan");
}
}

/*SAMPLE OUTPUT
1. French
2. Spanish
3. Russian
4. Italian
5. Japanese
6. German
7. Korean
8. Arabic

Please select the language (1-8) in which you want to display a greeting: 2
Hola
*/

Add a comment
Know the answer?
Add Answer to:
Choose 3 of 5 Problems to Solve Need Soon as possible Choose 3 of5 Problems to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The answer need to write in C programming. QUESTION 2 Write a program using array to...

    The answer need to write in C programming. QUESTION 2 Write a program using array to generate a multiplication table based on the user's input. For example if user enter 5 as input then a multiply table for 1 to 5 is printed as output as shown in Figure Q2. There are three main steps in this program which are: Print rows (a) (b) Print columns Print multiplication of data inside table (c) Select C:\example1 \bin\Debuglexample 1.exe enter the value...

  • I need the pseudocode and python for the four attached problems: 1. (Chapter 5 - For...

    I need the pseudocode and python for the four attached problems: 1. (Chapter 5 - For Loop) Logic Technical College has a current tuition of $10,000 per year. Tuition is scheduled to increase by 5% each year. Using a FOR loop, design a program that calculates and displays the tuition each year for the next ten years, like so: The tuition for year 1 will be: 10500.00 The tuition for year 2 will be: 11025.00 ……….. (You, of course will...

  • Program in C++! Thank you in advance! Write a menu based program implementing the following functions: (1) Write a funct...

    Program in C++! Thank you in advance! Write a menu based program implementing the following functions: (1) Write a function that prompts the user for the name of a file to output as a text file that will hold a two dimensional array of the long double data type. Have the user specify the number of rows and the number of columns for the two dimensional array. Have the user enter the values for each row and column element in...

  • Write a menu based program implementing the following functions: (0) Write a function called displayMenu that...

    Write a menu based program implementing the following functions: (0) Write a function called displayMenu that does not take any parameters, but returns an integer representing your user's menu choice. Your program's main function should only comprise of the following: a do/while loop with the displayMenu function call inside the loop body switch/case, or if/else if/ ... for handling the calls of the functions based on the menu choice selected in displayMenu. the do/while loop should always continue as long...

  • In Matlab Create a single script (.m file) to solve these problems. Unless directed otherwise, use...

    In Matlab Create a single script (.m file) to solve these problems. Unless directed otherwise, use meaningful variable names for each variable; do not use the default variable ans to store your results. For this project, suppress your output with semi-colons (;). Each problem should be in a separate cell, using the cell mode feature of MATLAB. Problem 4 Video games are rather complicated to program, not least of which because of the graphics work that needs to be completed...

  • For Python-3 I need help with First creating a text file named "items.txt" that has the...

    For Python-3 I need help with First creating a text file named "items.txt" that has the following data in this order: Potatoes Tomatoes Carrots. Write a python program that 1. Puts this as the first line... import os 2. Creates an empty list 3. Defines main() function that performs the tasks listed below when called. 4. Put these two lines at the top of the main function... if os.path.exists("costlist.txt"): os.remove("costlist.txt") Note: This removes the "costlist.txt" file, if it exists. 5....

  • Write a code using loop and flag function in python jupitior notebook: Ask the user for...

    Write a code using loop and flag function in python jupitior notebook: Ask the user for the number of items they bought. Also ask the price of each item they bought and quantity purchased. Display the total amount they owe. Ask the user for a number n. Calculate 1+2+3+….+n. Ask the user for a number n. Calculate 1*2*3*…*n. Ask the user for number of rows (r) and columns (c). Print * for r rows and c columns. Ask the user...

  • I'm a little crunched for time and need some help with these first two questions. Thank...

    I'm a little crunched for time and need some help with these first two questions. Thank you! Question 1.) Write a Java program that reads in sequence of integers from the user until user enters a negative number and stores them in an Integer ArrayList. Once read, display a bar chart based on the values stored in the ArrayList. For example, if the user inputs 2, 5, 3, 8, 4, and -1, then your program should display the bar chart...

  • In python 3 What you need to do? 1. 2. 3. Create a function implementing the...

    In python 3 What you need to do? 1. 2. 3. Create a function implementing the logic to a Pascal triangle. (You can use any logic of your choice to generate the triangle) Read an integer input from the user, to determine the number of rows to be generated in a Pascal triangle. Call the function by passing the input as an argument to the function. Hint: You can use a list of lists to store the values of a...

  • need help!! c++ HW_6b - Calculate the average Use a do-while loop Write a program that...

    need help!! c++ HW_6b - Calculate the average Use a do-while loop Write a program that first prompts the user for an upper limit: Enter the number of entries: 5 € (user enters 5) After the user enters a number, the program should prompt the user to enter that many numbers. For example, if the user enters 5, then the program will ask the user to enter 5 values. Use a do-while loop to add the numbers. o With each...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT