Question
Use a back-end software component written in Java that meets the following criteria: use the customer's and purchase information to approve or send an item
Use a back-end software component written in Java that meets the following criteria:
use the customer's and purchase information to approve or send an item for warranty or Maintenace repair.
- Receives and processes user data, uses data types, design, and style.
- Executes back-end code. Contains a decision structure, an iterative structure, and a user designed function.
- Document the code and explain what it is accomplishing and how.
Submission Requirement:
- A screenshot of the GUI
- The documented back-end code that contains:
- a decision structure, if else statement
- an iterative structure, like a loop
- a user defined function, validation for an error on the input data
- functionality to receive and process user input data from the front-end GUI
- help make the code below better.
import java.util.Scanner;
public class WarrantyMaintenance {
// User-defined function for validating user input
public static boolean validateInput(String input) {
if (input == null || input.trim().isEmpty()) {
return false;
}
return true;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// input of user data
System.out.println("Please enter your name: ");
String name = scanner.nextLine();
System.out.println("Please enter your email address: ");
String email = scanner.nextLine();
System.out.println("Please enter the date of purchase (MM/DD/YYYY): ");
String purchaseDate = scanner.nextLine();
System.out.println("Please enter the warranty period in months: ");
int warrantyPeriod = scanner.nextInt();
// Executes the back-end code
boolean isValidInput = validateInput(name) && validateInput(email) && validateInput(purchaseDate);
if (isValidInput) {
System.out.println("Thank you for submitting the warranty information.");
System.out.println("We will send you a confirmation email a soon as posible.");
// Iterative structure the for loop
for (int i = 1; i <= warrantyPeriod; i++) {
System.out.println("Your warranty is good or valid for " + i + " months.");
}
} else {
// Decision structure for the if-else statement
System.out.println("Invalid input or data; please try again.");
}
}
}
Step by Step Solution
3.42 Rating (155 Votes )
There are 3 Steps involved in it
Step: 1
The provided code is a Java program for processing warranty information based on user input It collects user data validates it and then either proceed...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started