Answer:
import java.util.*;
public class BinaryToDecimal
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String binaryNumber;
int decimalNumber = 0;
System.out.print("Enter the binary number: ");
binaryNumber = input.nextLine();
for(int i=0; i<binaryNumber.length(); i++){
char c = binaryNumber.charAt(binaryNumber.length()-1-i);
int digit = Character.getNumericValue(c);
decimalNumber += (digit * Math.pow(2, i));
}
System.out.println(decimalNumber);
}
}
Explanation:
Create a Scanner object to be able to get input from the user
Declare the variables
Ask the user to enter the binaryNumber as a String
Create a for loop that iterates through the binaryNumber. Get each character using charAt() method. Convert that character to an integer value using Character.getNumericValue(). Add the multiplication of integer value and 2 to the power of i to the decimalNumber variable (cumulative sum)
When the loop is done, print the decimalNumber variable
Answer:
Have a place for the who team can access all the information they need and use to put their work for project managers to check-up on. Having a when everything is organized in one place, the work will be much smoother.
Answer:
GridBagLayout,FlowLayoutManager
Explanation:
LayoutManager interface is the interface used for laying out containers.Components like Button,text boxes are placed by Layout Manager,it is used to determine size and position of components in a container.
We can implement this interface via many classes like -
SpringLayout, SynthScrollBarUI, ViewportLayout , FlowLayout, GridBagLayout, GridLayout etc.
GridBagLayout-This layout arranges the components in vertical,horizontal or in baseline irrespective of their size.The orientation of the GridBagLayout depends on the container's ComponentOrientation property.
GridBagLayout is associated with an instance of GridBagConstraints which manages each component.
FlowLayoutManager-This layout arranges the components in a directional flow. The alignment of line is determined by componentOrientation.
ComponentOrientation .LEFT_TO_RIGHT
ComponentOrientation.RIGHT_TO_LEFT
Answer:
The Anonymous Block will be:
1 DECLARE
2
3 lv_grade_row grade%rowtype;
4 lv_gr_avg grade.gr_t1%type;
5 lv_std_name varchar2(80);
6 cursor cursor_grade is select * from grade;
7
8 BEGIN
9
10 select avg(gr_t1) INTO lv_gr_avg from grade;
11 open cursor_grade;
12 fetch cursor_grade INTO lv_grade_row;
13
14 while cursor_grade%found loop
15
16 if
17 lv_grade_row.gr_t1>lv_gr_avg then lv_std_name :=
lv_grade_row.std_fname|| ' ' ||lv_grade_row.std_lname|| ' ' ||
lv_grade_row.gr_t1;
18 dbms_output.put_line(lv_std_name);
19
20 end if;
21 fetch cursor_grade into lv_grade_row;
22
Explanation: