Module 2 Assignments
Module 2 Assignments
Assignment 1:
Create a Java program that calculates and displays the cost of purchasing a specified number of items, each priced at a
certain amount, with a given tax rate and discount. The program should perform calculations using various operators in
Java, without using objects and classes and without user input. The program should display the total cost, including tax
and discount.
Create a Java program that simulates a simple dice game without using objects and classes and
without user input. The program should allow two players to take turns rolling a standard six-sided
die (with numbers 1 to 6). Each player rolls the die once per turn, and the program keeps track of the
total score for each player. The game should continue until one of the players accumulates a predefined winning score.
Assignment 3:
You are given a sentence as a string in Java. Your task is to reverse the order of the words in the sentence while
preserving the order of the characters within each word.
Write a Java program that takes an input sentence, performs the word reversal, and prints the modified sentence.
Assignment 4:
You are tasked with writing a Java program to analyze daily temperature data for a week. The program should take the
following input: