import java.util.*;
class App {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String names[] = new String[15];
double salaries[] = new double[15];
double salariesTotal = 0;
for (int i = 0; i < names.length; i++) {
System.out.print("Enter employee name " + (i + 1) + ": ");
names[i] = in.nextLine();
System.out.print("Enter employee salary " + (i + 1) + ": ");
salaries[i] = in.nextDouble();
salariesTotal += salaries[i];
in.nextLine();
}
System.out.println();
for (int i = 0; i < names.length; i++) {
System.out.println("Enter employee name: " + names[i]);
System.out.println("Enter employee salary: " + salaries[i]);
}
double averageSalary = salariesTotal / 15.0;
System.out.printf("The average salary employees: %.2f\n", averageSalary);
in.close();
}
}
Do this coding without using array and printf
Write a program to take a String name as input then display the signature using substring().
Example:
Enter a String
Chandra Bahadur Dangi Ailen Coq
C. Bahadur D. Ailen C.
Don't use Array & Split
import java.util.*;
class App {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter a String: ");
String words[] = in.nextLine().split(" ");
for (int i = 0; i < words.length; i++) {
if (i % 2 == 0) {
System.out.print(words[i].substring(0, 1) + ". ");
} else {
System.out.print(words[i] + " ");
}
}
in.close();
}
}
Do this program without using array and split
Write a program to calculate the net salary of an employee using the concept of structure.
Write two subclasses of Shape called Circle and Rectangle, as shown in the class diagram.
a) The Circle class contains:
· An instance variable radius (double).
· Three constructors as shown. The no-arg constructor initializes the radius to 1.0.
· Getter and setter for the instance variable radius.
· Methods getArea() and getPerimeter().
· Override the inherited toString() method, to return "A Circle with radius=xxx, which is a subclass of yyy", where yyy is the output of the toString() method from the superclass.
b) The Rectangle class contains:
· Two instance variables width (double) and length (double).
· Three constructors as shown. The no-arg constructor initializes the width and length to 1.0.
· Getter and setter for all the instance variables.
· Methods getArea() and getPerimeter().
· Override the inherited toString() method, to return "A Rectangle with width=xxx and length=zzz, which is a subclass of yyy", where yyy is the output of the toString() method from the superclass.
a) Write a class called Square, as a subclass of Rectangle. Convince yourself that Square can be modeled as a subclass of Rectangle. Square has no instance variable, but inherits the instance variables width and length from its superclass Rectangle.
· Provide the appropriate constructors (as shown in the class diagram). Hint:
public Square(double side) {
super(side, side); // Call superclass Rectangle(double, double)
}
· Override the toString() method to return "A Square with side=xxx, which is a subclass of yyy", where yyy is the output of the toString() method from the superclass.
· Do you need to override the getArea() and getPerimeter()? Try them out.
· Override the setLength() and setWidth() to change both the width and length, so as to maintain the square geometry.
a) Write a superclass called Shape (as shown in the class diagram), which contains:
· Two instance variables color (String) and filled (boolean).
· Two constructors: a no-arg (no-argument) constructor that initializes the color to "green" and filled to true, and a constructor that initializes the color and filled to the given values.
· Getter and setter for all the instance variables. By convention, the getter for a boolean variable xxx is called isXXX() (instead of getXxx() for all the other types).
· A toString() method that returns "A Shape with color of xxx and filled/Not filled".
Write a test program to test all the methods defined in Shape.
Student information Window
The data should be saved in a file.
The student record may be deleted.
The student record may be searched based on the ID provided.
The student record may be updated in case if its phone no or house address changes.
Write a python function C-F(X) which takes a dictionary containing numbers as input. The function will return a dictionary containing key as a number and value as frequency of how many times the number is repeating in the dictionary. For Ex: 1) {'V': 10, 'VI': 10, 'VII': 40, 'VIII': 20, 'IX': 70, 'X':80, 'XI': 40, 'XII': 20 } is input , then output is { 10: 2 , 20: 2 , 40:2 , 70: 1 }.
2) input: {1: 10, 2: 20, 3: '30', 4: '10', 5: 40, 6: 40} output: {10: 1, 20: 1, '30': 1, '10': 1, 40: 2} .
Function should be general and should work for any finite items dictionary.
is programming example taken out of the textbook by D.S. Malik demonstrates a program that calculates a customer’s bill for a local cable company. There are two types of customers: residential and business. There are two rates for calculating a cable bill: one for residential customers and one for business customers. For residential customers the following rates apply:
For business customers the following rates apply:
write the flowchart and pseucode for question